Check event parameters on Google Analytics dashboard - google-analytics

I have recently started working on Google Analytics. I have added the following script just after the head tag
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-X"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-XXXXXXXX-X');
</script>
Now i am inserting another script to create an event. After doing this , when i visit Google Analytics dashboard and go to REAL-TIME->Events->bottom most table , i can find the 'Event Category' with value 'engagement' and 'Event Label' as 'generate_lead' but how do i see other parameters that I am passing like 'value','currency' and 'transaction_id'. I want to check these parameters as well but i can't find it anywhere . Also can i map my own key-value pairs with the event by adding my custom parameters just like 'value','currency' and 'transaction_id' (which are already defined parameters associated with 'generate_lead' action) ?
gtag('event', 'generate_lead', {
'value': '2',
'currency': 'USD',
'transaction_id': '1234'});

Related

ga to gtag in custom dimension in combination with custom reports and virtual pageviews

In the past I used a Google Analytics Custom Report to track the amount of pageviews per author and number of pageviews per forum topic category which I had setup like this in Google Analytics (analytics.js):
The code I used to push this data to Google Analytics was simple ga('set', 'dimension1', 'Name of Author');
I've updated my Google Analytics javascript snippet to gtag but I can't seem to push the data in the same way.
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-xxxxx"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-xxxxx',
{ 'anonymize_ip': true,
'forceSSL': true,
'custom_map': {'dimension1': 'author', 'dimension4': 'forum_name'}
});
gtag('event', 'author', {'event_category': 'Writers', 'event_label': 'Author Name'});
gtag('event', 'forum_name', {'event_category': 'Forum category', 'event_label': 'Forum Category name'});
</script>
At the moment I am getting the data as an event in Google Analytics. But the way the code works right now makes it much harder to analyse the data. In the past I could click on an authors name and see which pages got the most pageviews and for the forum category it was the same. I could dig in and see per category the urls that brought in the most visitors.
I think the difference between the two code snippets is that ga 'set' was sent as a virtual pageview where the net gtag 'event' is an event and not an virtual pageview. The question now is how to setup a similar custom report as I has previously or how to update the code snippet to get a similar result as in the past?
Update
This is the old version of Google Analytics and the code I've been using:
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXX', 'auto');
ga('set', 'dimension1', 'Author Name');
ga('set', 'dimension4', 'Forum name');
ga('require', 'ec');
ga('set', 'anonymizeIp', true);
ga('set', 'forceSSL', true);
ga('send', 'pageview');
</script>
After a lot of testing I finally found the answer to my own question. The trick seems to be to add the dimensions in the config so they are send as a pageview.
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-xxxxx"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-xxxxx',
{ 'anonymize_ip': true,
'forceSSL': true,
'dimension1': 'Author Name', 'dimension4': 'Forum category'
});
</script>
Based on your analytics.js code, the set command sets the custom dimensions and their given value so that they persist and send with all/any hits within the page. The example code snippet that was being used for analytics.js, is sending the cd's along with the default pageview.
Try instead
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('set', {'dimension1': 'Author Name', 'dimension4': 'Forum name'});
gtag('config', 'UA-xxxxx',
{ 'anonymize_ip': true,
'forceSSL': true
});
</script>
If you have any onclick or other events being sent within the page, or virtual pageviews being sent within the page, it will also send the above custom dimensions and their set values with those too.
After doing some testing custom_map doesnt appear to be necessary (however it may come into play with the new app+web properties and possibly where the gtag.js snippet is used for multiple products and custom parameters need to be mapped).
Not sure, however I found custom_map somewhat strange in it's behaviour when i did some testing with it.

Google Analytics Goal Events using gtag code not working

I've tried many different permutations of gtag and ga codes and I can't seem to get a positive conversion on Google Analytics.
This code runs on form submit and the Google Ad conversion in the first line registers a positive conversion in that platform. Google Analytics is what isn't showing the goal.
I'm NOT using the Google Tag Manager, but including the following global tag.
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'XXXXXXXX');
</script>
As you can see here the lines I've marked as the attempts are as follows:
// This Google Ad Conversion works properly
gtag('event', 'conversion', {'send_to': 'XXXXXXXX'});
// Attempt 1
gtag('event', 'Submit', { 'event_category': 'Form', 'event_label': 'Outdoor Kitchens Landing Oct 2019', 'value': 1 });
// Attempt 2
ga('send', 'event', 'Form', 'Submit', 'Outdoor Kitchens Landing Oct 2019', 1);
// Attempt 3
ga('send', {
hitType: 'event',
eventCategory: 'Form',
eventAction: 'Submit',
eventLabel: 'Outdoor Kitchens Landing Oct 2019',
eventValue: 1
});
In order to make the ga code work, I had to include the following snippet in the HEAD.
<script>
window['GoogleAnalyticsObject'] = 'ga';
window['ga'] = window['ga'] || function() {
(window['ga'].q = window['ga'].q || []).push(arguments)
};
</script>
The setup of the goal in Google Analytics is as follows (the label that is cut off reads "Outdoor Kitchens Landing Oct 2019"
Consider adding gtag('config', 'UA-XXXXX-Y') call to initiate analytics tracking and following the official documentation on analytics event tracking: https://developers.google.com/analytics/devguides/collection/gtagjs/events
From what I see on your site, the analytics tracker object is never initiated so no data are sent to Analytics.
You need gtag('config', ... ) call for each service you're using like one for Ads conversions and another for Analytics: https://developers.google.com/gtagjs/devguide/configure
also, your MonsterInsights code might affect tracking so check if it works as intended.

gtag events not registering in analytics

I've looked at countless answers but been unable to find the right solution. I'm trying to get Google analytics to register a goal once a contact number has been clicked, using an event registration (onclick).
I've got the following code, which is not registering any results. What's the thing I'm missing?
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXX-XX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-XXXXXX-XX');
</script>
onclick="gtag('event', 'click', { 'send_to': 'UA-XXXXXX-XX', eventCategory: 'Telefoon ', eventAction: 'click', eventLabel: 'Telefoonnummer aangeklikt', eventValue: 1});"
The syntax for the onclick code is incorrect.
send_to is not necessary if only a single tracking code is being used on the site. If more than one tracking code is in use then you can configure it to send (or route) data to individual GA Properties or groups of accounts or products.
Ref: https://developers.google.com/gtagjs/devguide/routing
event tracking syntax is the following:
gtag('event', 'action', {'event_category': 'category', 'event_label': 'label', 'value': value});
ref: https://developers.google.com/analytics/devguides/collection/gtagjs/events
event_label and value are optional.
The following should work for your link
onclick="gtag('event', 'click', { 'event_category': 'Telefoon', 'event_label':'Telefoonnummer aangeklikt', value: 1 });"

To get event corresponding to page load time in Google Analytics

I want to track page load time using google analytics. I have a single page application . In order to track i added the given script inside head tag . And in order to get page load time , i added the second script just before the body tag but unfortunately i am not able to find any event in Google Analytics corresponding to this . It seems like this gtag() is not executing somehow. Can someone please help out. Also where do we see event_value in Google analytics. I am able to find event_category and event_action by going into RealTime->Events but i can't find any event_value there.
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-X"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-XXXXXXXX-X');
</script>
<script>
if(window.performance){
// Gets the number of milliseconds since page load
// (and rounds the result since the value must be an integer).
var timeSincePageLoad = Math.round(performance.now());
// Sends the timing event to Google Analytics.
gtag('event', 'timing_complete', {
'name': 'load',
'event_value': timeSincePageLoad,
'event_category': 'Home page loading time'
});
}
</script>
According to documentation it should be value, not event_value
gtag('event', 'timing_complete', {
'name': 'load',
'value': timeSincePageLoad,
'event_category': 'Home page loading time'
});

Dimension only tracks one Customer

I'm stumped. We only get one fruit type showing up in analytics when there should be multiple showing up for pageview tracking per fruit type;
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{analyticsAccount}}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{analyticsAccount}}', {
'custom_map': {
'dimension1': 'fruitType',
'dimension2': 'userId',
}
});
gtag('set', 'fruitType', {{fruitType}});
gtag('set', 'userId', '{{userId}}');
</script>
<!-- end global site tag -->
For some reason, it's only showing one fruit type when looking at either custom or standard reports and we know our system is sending in many types of fruit.
Unfortunately I don't have a public page I can share.

Resources