Hey Observable Community!
I’m trying to set up Google Analytics on a notebook and have tried all the implementations on these forums (I started here: Embedding Google Analytics - good or evil - poll - #4 by mbostock). I haven’t been able to get GA to receive any data from the notebook. I’m having trouble isolating where the problem is because as far as I can tell I’ve implemented the code correctly. Any ideas on how to debug the integration at all?
There could be a variety of causes. Can you share a link to your notebook?
For starters, you’ll want to open the network tab in your browser’s developer tools and check if Analytics sends any requests. Here you’ll also see if its attempts get blocked.
Next, be aware that the worker domain is different from the notebook domain. This may affect how GA processes the received data for the configured property.
I am also struggling. Did you get it working? I have tried 4 different accounts, universal analytics and GA4, and I cannot get it to work I am not sure how it should be configured analytics side. Whether its observable domain or my subdomain (I tried both, but sometimes its laggy)
Not sure if this helps, but the origin for your code in observable can be found by typing this in your notebook:
which in my case shows:
Again, not sure if this is useful…
A fair number have wired GA up: (Observable. So not sure why mine is not working. I switched to UA + personal origin today I guess I will eventually get there. Would be helpful though if anyone has a working one to tell me how its configured w.r.t. to subdomains.
Here is a link to the notebook (Page Analytics / Zachary Alan Kwiecinski / Observable), I have been able to see GA requests go through and to my knowledge they aren’t being blocked.
Thanks is the GA side setup as a property as owned by
In your notebook prose you state using a UA-XXX which is a universal analytics integration but your code is using a G-XXX code which is the later GA 4 integration. Which did you use and have working?
Probably none of these things are that important but I would like to know for the record.
I suspect its my consent mode that is messing things.
yeah I don’t think its critical the primary domain. For a GA4 is Admin → property → Data streams
Seems like its just something weird my end. Could be additional German requirements…
Yeah I still haven’t been able to get this working. To my knowledge the project I’m trying to set this up for only had it working for a couple hours almost a year ago so there was no guarantee that the code they used would still work. Especially after the big GA update that happened a few weeks ago.
Yeah I haven’t been able to get this working yet either, ran out of time to investigate, but seems they might actually require you to put it in the head tag now?
I thought the issue had something to do with the worker process / url differences but I’m not positive. If it isn’t possible to do through regular notebook code anymore, I wonder if Observable might support some method outside of the notebooks to add it.
Plausible Analytics works ok and it’s about 5 min to setup :-
Cool! I seem to have at least partially fixed it by manually changing the upload payload. And I can publically share my stats and even embed the plausible dashboard in a notebook!
Out of all the analytics options, I think plausible is the least bad, it actively tries to avoid personal information so no GDPR consent is required (so they say, IANAL), and it provides all the hooks for total transparency. I shared all endpoint services stats!
Some outstanding issues with Plausible Analytics
Whats good about the plausible analytics client is that it is quite hackable if you can somehow get the right information to it.
Have started using Plausible off of your notebook, thanks for exploring this! I have also noticed the two issues you mentioned.
Regarding the second one, one partial solution might be to try to include the title of the notebook (fetched either through metadata if the script can access that, or from the text of the top cell). This would at least tell you which notebooks are embedded, if not where they are embedded. Might try this out and see if it works reliably.
Interesting I have an ink simulator that went viral enough to be linked in other sites. Mostly I lose this information but this site added ?ref=creativebrew and then it got picked up as a referrer in Plausible
Note the referer was not a domain name but just ‘creativebrew’ which was enough. This doesn’t really satisfactorily solve the referrer issue but it is interesting that sometimes information gets through.