Cannot create reports for custom dimensions/metrics GA4 - google-analytics

I have implemented a feedback star rating on my website at the bottom of each page. They can select one to five stars and optionally send free-form comments. I have implemented gtag.js to send the star rating integer and comments to my GA4 dashboard. Code snippet is below; I have omitted the JavaScript which allows the user to set the variables, but this is working.
<script async src="https://www.googletagmanager.com/gtag/js?id=MEASUREMENT_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'MEASUREMENT_ID', {
'custom_map': {
'rating_dimension': 'rating_key',
'comments_dimension': 'comments_key'
},
'rating_key': 'this.value',
'comments_key': 'commentsValue',
});
</script>
gtag('event', 'rating_event', {'rating_key': this.value });
gtag('event', 'comments_event', {'comments_key': commentValue });
I went under Configure>Custom definitions and added the dimensions under the Event scope.
The data is being sent as an event, because this is something the user can optionally do on a page. I have verified that the data is sent to GA, I have the Google Chrome GA Debugger, and can see that it is arriving in the Realtime report under Events.
I would like to build a report which shows the page title/URL, the number of views, the length of time spent, along with its average star rating and any comments. I would like to have some adjustable controls so that I can configure this to be shown for a specified length of time. For example, if the page is modified, I can see the average rating before and after the change. Unfortunately, I am not able to build even the most rudimentary view of this data in the new GA web interface. I tried to modify various existing reports to include my custom dimensions, but they don't offer this option. I went under Explore and tried to add a Freeform report, but I can't get the data to show up there either, it only counts the number of times the event has occurred, which is not what I care about at all.
I have gone to a lot of effort to send the data to GA and had expected to be able to access the data and build a basic report.

Is it that you are unable to add custom dimensions and metrics to the free form exploration? Or when you want to add dimensions or metrics, they don't even show up in the custom section?
Normally you have to wait more or less (some say up to) 24 hours before being able to use custom definitions (metrics and dimensions) in any report.
this might not be your case, but I found your post looking for an answer to my problem, which is the custom metrics and dimensions are there, I am just unable to add them to the report, it looks like a bug, I click the + button, check the custom dimensions and nothing happens.

Related

(not set) values from session_start events appearing for custom dimensions/parameters

We just added GA4 tracking to our website, along with custom parameters on events that were then configured as custom dimensions to be used in reports. After, we noticed "(not set)" values appearing when breaking out by a custom dimension. It appears as 0 Views, but roughly double the Total Sessions.
When filtered to "(not set)" for the custom dimension, and looking at the events, it seems these are mostly recorded as "session_start" and "first_visit" events.
Moreover, when filtering out "(not set)" for the custom dimension, the Sessions count for the page_view event does not add up to total, which leads me to think that there are Sessions with no page_view events - though I can't think of how this could happen on our site, and we don't have an app/any app tracking set up.
We compared and we get the same results from the API too.
Here is the code on our site (following the gtag guide here):
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXX"></script>
<script>
var ga4ParamsObject = JSON.parse(`{"classification":"Standard","example1":"value1","example2":"value2","example3":"value3"}`);
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXX', ga4ParamsObject);
</script>
Questions:
Is something incorrect or missing from our implementation that's resulting in (not set) values appearing on custom dimensions?
Are we not "linking" session_start and first_visit events to page_view events within the session?
What can explain the Total Sessions being higher than the count of sessions with a page_view event?
It would appear that multiple parameters within the same session are counted twice when breaking out by these parameters (custom dimensions) - is that expected in GA4 or again something incorrect with our set up?
Additional notes:
We are running analytics.js in parallel
We've upgraded to 360
"Collect UA events in GA4" setting is turned off in Admin config
The GA4 property is connected to GAM, we serve ads on the page, and some advertisers do use gtag.js too, but I checked multiple times and our specific G- measurement ID only appears in the snippet I shared above
Here's an example page
Thanks to anyone reading this.
Custom parameters are currently not tracked with the session_start and first_visit automatically collected events which is why your custom parameters are (not set) with these two events.
Unfortunately this can impact your reporting depending on the metrics you use. E.g. if you use the views metric only and assuming your custom parameter is always set you will not see the (not set) value in your report. However if you use the users metric you will see the (not set) value as users will include events such as session_start where the custom parameter is not populated.

Trouble recreating Google Analytics (UA) events in GA4

I have a bunch of mp3s and an audio player on my site. In GA3 (UA) I had an event that fired every time I hit the play button on a specific track. The event name was jPlayer, the track in question is the variable 'mediaName', which is the name of the mp3 file which is derived when I click play. In my code, mediaName is a string that gets sent out to GA. i.e. mediaName might be 'mycooltrack.mp3', or 'anothergoodtrack.mp3'
ga ('send', 'event', 'jPlayer', mediaName);
After reading the GA4 docs, I guessed that I needed to make a custom dimension, called "Track" which took the User Property/Parameter: mediaName.
So the new code in my function looked like:
gtag('event', 'jPlayer', {
'Track': mediaName
});
But after several days this hasn't been working either.
I guess I don't really understand what dimensions are and how to send an event with an 'on-the-fly' name variable to GA4, like I've been doing with UA for years.
You need to first create the event in GA4 interface. https://support.google.com/analytics/answer/10085872?hl=en&ref_topic=9756175#zippy=%2Cin-this-article%2Creserved-prefixes-and-event-names%2Cweb
It is under "Configure" on the left-hand side. Then go through the steps.
Your configuration will look something like this, if you really like the "jPlayer" event name, then just replace "audio_play" with "jPlayer"
The code you used is still relevant and can stay the same, I'd just write "track" in lowercase.

Using a Google Analytics custom dimension for pageview statistics widget

I have a custom dimension that is being set with a gtag tracking code. I can actually see that the values are being send to GA and can, for example, make dashboard widgets with it.
The odd thing is that when I make a widget with sessions and the dimension it works well, but if I want to make a widget with pageviews and the dimension it returns no data at all.
This is my tracking code:
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-0000000-0', {"anonymize_ip":true,"custom_map":{"dimension1":"premium"}});
gtag('set', 'premium', {'premium': 'premium post and not subscribed'});
I've also, instead of using 'set' tried using 'event' but this did not solve the issue. It looks like the custom dimension is not being collected with pageviews, but with sessions only.
Does anyone know if I have to configure it differently to also make it work for pageviews?
Since your custom dimension is configured at the hit level it needs to be associated with either an event or pageview hit. Your code looks like it simply sets the custom dimension value, but it's not followed by a pageview hit call. Try swapping the idea of your calls instead:
gtag('set', 'premium', {'premium': 'premium post and not subscribed'});
gtag('config', 'UA-0000000-0', {"anonymize_ip":true,"custom_map":{"dimension1":"premium"}});

Custom reports are empty in Google Analytics receiving data from Google Tag Manager

I want to create a custom report with custom dimensions and custom metrics, so I've created them as admin in GA and both have index 1.
I've added them in the dataLayer in my code:
var dataLayer = {'dimension1':'Custom Dimension 1','metric1':123456}
And after setting in GTM, I've checked data is being sent right in live mode:
But custom reports are empty, but activity on site is being registered.
This is the entire code of my site. I have tried adding both Google Tag Manager and Google Adwords codes but does not work in any case:
<body>
<script>
var dataLayer = [{
'dimension1':'My Custom Dimension 1',
'metric1': 123456
}]
</script>
<!-- Google Tag Manager -->
<!-- End Google Tag Manager -->
<h1>Nuevo alojamiento</h1>
<script>
//GA CODE
ga('create', 'UA-76206495-2', 'auto');
ga('send', 'pageview');
</script>
</body>
Pushing those values with those standard reference names in to GTM will not associate them with your hits, or make them show up in your reports. In GTM you need to grab the value of your CD and CM from the dataLayer. In this case you need to create dataLayer type variables that will give you access to dimension1 and metric1, although I would advise to rename them to something else other than the standard GA reference names, ie. dimensionX and metricX because that could be confusing. Then you need to pass the index and value for that CD and CM into whichever tag (page view, event, etc.) using those new names.
Edit: note that data won't show up in your standard reports until they have been processed, which takes up to 24 hours or so.
As nyuen told me, I have to set those values in GTM, it was done bescause, if it wouldn't, data would not been sent. These are my settings
This sends the CD and CM in all pages. Custom vars are already set.
Preview mode of CTM displays this, it was fired:
And de dataLayer contains the data (I'm going to follow you advice and use another name):
So if I leave the preview mode and publish in GTM, I'm sure information is being sent, that is the GET request I placed before. Those values era in the URL as params (cd1 and cm1), so that is the reason why I'm pretty sure information is being sent to GA
Hope this extra information helps
UPDATE 1
I've changed dataLayer values to dim1 and met1 and now met1 is set to 123456789. Also, verified UA is right.
With those changes, chain sent to Google Analytics is the same (params are cd1 and cm1 with the appropiate values)

How to Track Store Locator Search terms in Google Universal Analytics

I am in the process of setting up enhanced Ecommerce for GA and have had a few requests of additional of what else the client would like to see in their reports. Once of which is
"Where can i see a report if the locations that a use types in when they use the store locator"
There is already an internal search functionality thats been set up and is tracking the search terms people are typing when looking for products, but i'm not sure if i would need to set this up as a second search terms report or if it's something different?
The URL of the page is different to the internal search results and is www.domain.com/store-locator#wales|GB|0|0|0
Any insight into this would be really helpful.
Thanks,
Roxi
As to me knowledge, you are not able to use bookmarks (#something) in GA for internal site search setup. Only GET and POST parameters are allowed. In your situation I think the best solution is to use GA events to send the data about used location each time the user is using this functionality. You need to include addition ga() function call to track those events. Info about how to set it up you could find here: event tracking. After setting things up, you will see all the info about number and type of called events in Behavior -> Events reports section in GA.
Example code:
<button onlick="var hash_location=window.location.hash;ga('send','event','Locator',has_location)">Click me</button>
With such function new event will be send to GA with Event Category=Locator and Event Action=hash in the url. You have some complicated hash, so most probably you need to extract first some info from this using regular expression. Example to get first item from |-separated list in the hash:
var pattern = new RegExp('[^#|]+');
var hash_location = pattern.exec(window.location.hash)[0];

Resources