🏠 back to Observable

Google Analytics unable to connect to notebook

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.

1 Like

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

  1. observablehq.com or
  2. ____.static.observableusercontent

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.

  1. I don’t believe it’s owned by either of those. It’s under our business account. But where would I confirm this?
  2. Sorry about that, the notebook was forked from a different forum post about GA but it was made at a time when the UA-XXX codes were in use. The G-XXX code is what is provided in the GA dashboard.

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.

1 Like

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 never got it working

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 :-

1 Like

well actually it still kinda sucks as the paths are all gibberish like:


I wonder if there is a way to configure them to look sane