GA4 report on clicks by 'item_name' and 'item_brand'
Asked Answered
V

1

6

I'm using the GA4 measurement protocol from a PHP backend for tracking "click" events. I don't control the site where the clicks happen, so I'm creating custom tracking URLs which will be used to redirect via my PHP backend, which will in turn perform a fire-and-forget POST https://www.google-analytics.com/mp/collect before redirecting to the user's actual intended destination.

I can see the events are indeed reaching GA4 because they show up in my Events report, however I'm not able to see any dimensions like "item_name" or "item_brand". Can anyone tell me how I can see a weekly click report that is broken out by item and brand?

Vetavetch answered 1/9, 2023 at 22:40 Comment(1)
Do you have enabled the Enhanced Measurement setting in your GA4 property?Garvey
C
0

Short answer: Try to not use the measurement protocol unless you're sure there's no other way. MP is messy, and GA4 certainly didn't make it better.

Long answer: Inspect a standard GA call to the collect endpoint even on this page. See how many dimensions are set in it even if just by default:

enter image description here

Now most of them are vital for reporting. They keep track of a bigger picture. GA wasn't meant to be used as a debugging tool where you can just send a few dimensions arbitrarily and expect them to be available.

The issue with using the measurement protocol and normal tracking interchangably is that you have to make sure at least the session id and the client ids are synced inbetween (cid and sid in the screenshot). You have to also carefully keep track of the referrer, document location and document path (dl, dp, dr) parameters on your backend. But probably even more.

While it's doable to mix the two protocols, it's rarely viable. Just too much back-end work involved.

There are better solutions to your problem.

  1. A classical solution would be UTM parameters. They allow you to hardcode dimensions in the urls to be published on third party sites via query parameters. Once the user gets to your site with those parameters in the URL, the front-end GA lib will consume them and you will be able to report based on those parameters.
  2. If you can't mutate your links on the third party site, you could use your backend to rewrite it on the fly and inject the utm params through the backend for the FE to consume.
  3. Finally, UTM params tend to set the source and medium besides the campaign, platform, and other optional dimensions. That might be more than what you need. In that case, I would suggest using your backend to set a cookie (or the state, or the query params, however you communicate with the FE) for the front-end to consume. On the front-end, before sending the GA pageview, you consume the cookie and then set any fields you want in that pageview. This is a good solution too.

If you're setting custom fields (also known as event parameters), you need to make sure you're registering them in GA4 interface as custom dimensions. Don't forget that your data won't be available in reports immediately. Real time reports show it, but normal reports won't show it immediately. GA4 says for up to 48 hours for the events to show up, but it usually takes just a few hours.

Cleaning answered 7/9, 2023 at 18:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.