Google Analytics 4

Hi, Can you tell me if Google Analytics 4 is supported and if so what is the format of the web property ID for the Backlight settings?
Thanks very much
John

I don’t know about compatibility (Ben or Matt would know), but the format used can be viewed from the Google Analytics section of the Backlight Settings page:

image

Thanks Rod, The UA stands for Universal analytics and the Google Analytics uses GA4 as a prefix. Thats why I asked about the format. Will see if Ben and Matt have the answer.
Regards
John

Hi. First I’ve heard of GA4. I’m looking at it now, but it’s not immediately obvious how to implement it. I’ll need to spend some more time sorting it out.

In the meantime, I can tell you that Backlight’s implementation is based on Google’s Universal Analytics. If you need an implementation more customized, you can always disable this in Backlight, and embed your own code using PHPlugins.

Thanks Matt, It looks like GA4 is the future direction so appreciate that you will give it some attention.
John

With phplugins, it is easy to add. There is even a recommendation to run both in parallel for a time in order to be certain that everything works properly.

Here is the link for the code: https://developers.google.com/analytics/devguides/collection/ga4

1 Like

It is really very easy to add the GA4 tracking code using phplugins. I just did it on my site and I already get tracking data. To get started, here is the phplugins code I used https://lab.danielleu.com/blog/adding-google-analytics-ga4-to-backlight-4/

Thanks very much Daniel, your code stopped me getting the error messages with the code I was creating.
You wrote “In order that this code works, you need to have set Google Analytics Web Property ID in the Backlight admin settings.” The section in the setting has a particular format UA-xxx-x
What format did you use?

Yes, in Backlight it is the UA-xxx format and in my code it is the G-xxx format. This way my code takes advantage of the code provided by Backlight and at the same time, you can have both tracking formats linked in Google Analytics.

Thanks Daniel, All works now as intended
john

1 Like

Thanks Daniel, All works now as intended

Great that you got it working, John! And thank you for the coffee!