-
. Google Analytics 4 Custom Dimensions Not Recording: What Did I Miss?
So, here’s the deal. I’ve been trying to figure out how to get custom dimensions in Google Analytics working. Here’s a look at how I’ve set up my code:
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXX"></script> <script> window.dataLayer = window.dataLayer || []; function gtag() { dataLayer.push(arguments); } gtag('js', new Date()); // Set up custom dimensions for user ID and unit ID gtag('set', { 'user_id': @authorizationService.UserId }); // Grab unit ID from cookie and use that as a custom dimension var unitId = parseInt(getCookieValue('UnitFilter')); if (!isNaN(unitId)) { gtag('set', { 'unit_id': unitId }); } gtag('config', 'G-XXX'); function getCookieValue(name) { var value = "; " + document.cookie; var parts = value.split("; " + name + "="); if (parts.length == 2) { return parts.pop().split(";").shift(); } } </script>
I then went about configuring things in Google Analytics with these steps:
- Logged into Google Analytics.
- Clicked Admin, then picked the property I’m working on.
- In the PROPERTY column, clicked on Custom Definitions > Custom Dimensions.
- Clicked New Custom Dimension.
- Light-bulb on, added a name. In my case, I named it unit id
- Marked user as the scope
- And saved the whole shebang!
Here’s a screenshot of how things look:
Now I’m stuck. Is there some other step I’m missing? My unit id doesn’t seem to be interactive, and keeps telling me that there’s no data available. It’s been a sweet two days since I set this up, by the way:
Here’s another look at what’s going through:
Any clue about what I might be overlooking? All help appreciated. Cheers!
Log in to reply.