I know a low bounce rate is due to double tracking but I don't find the problem on that website
The tracking code is this one:
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-12345678-9"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-12345678-9', {
'custom_map': {'dimension1': 'Appli'}
} );
gtag('set', {'user_id': '1'});
gtag('event', 'page_web', {'Appli': 'non'});
</script>
I don't see how to remove something...
The problem is due to the fact that you are setting an event on page load. By default the gtag tag will first create a pageview hit that is sent to Google Analytics.
Then your gtag('event', 'page_web', {'Appli': 'non'}); call is fired. Because this is an interaction event, it will count as a user interaction, and thus the bounce rate for the page will be zero (a bounce is recorded if there are no interaction hits after a pageview hit on a single page).
I'm not sure what you are using the event for, but if it is something that is recording automatically, then I would suggest configuring it as a non-interaction event hit:
gtag('event', 'page_web', {'Appli': 'non', 'non_interaction': true});
Related
We would like to send GA4 event data to 2 different GA4 Measurement Ids. Can gtag.js be configured to do this?
We know this can be configured for UA and GA4, but what about two or possibly more GA4 Measurement Ids?
Yes you can set up the gtag like thie
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-111111111"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-111111111');
gtag('config', 'G-222222222');
gtag('config', 'G-333333333');
</script>
Then when you fire event:
<script>
gtag('event', 'test', {
'test_p1': 'test_v1'
});
</script>
You will send the ga4 event hits to all the config measurement in gtag.
But if you have more complicated requirements like
Event A to all config
Event B to some of the config
Please take a look at the document
I want to increase the Sample Rate for Page Timings from 1% to 10% in google analytics.
We are using Global site tag (gtag.js) for adding GA to our site.
Following is current config:
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-123456-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-123456-1');
</script>
As per the doc, the following will capture the user load time, but it won't increase the sampling rate.
// Feature detects Navigation Timing API support.
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',
'value': timeSincePageLoad,
'event_category': 'JS Dependencies'
});
}
This was solved by setting, gtag('config', 'UA-XXXX-X',{'site_speed_sample_rate': 100})
I am in need of assistance. I am trying to implement Custom Event Tracking for a form submission as both an Analytics Goal, and a Conversion Goal for Google Optimize.
Here is a screenshot of the Google Analytics Goal:
I have my Google Analytics in the head (with sensitive information redacted with XXXXX) as such:
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=XXXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'XXXXXXXXXXX', { 'optimize_id': 'XXXXXXXXXXX'});
</script>
And then I have tried to fire the custom event with both:
ga('send', {
hitType: 'event',
eventCategory: 'mailchimp',
eventAction: 'subscribe',
eventLabel: 'soft-lead-form'
});
and also:
gtag('event', 'play', {
'event_category': 'mailchimp',
'event_label': 'soft-lead-form'
});
I have confirmed that analytics is instanced effectively by writing to the console with:
if (gtag) {
console.log("ga present");
}
And I have confirmed that the user action triggers the ga call by writing to the console in the same function with:
$("#mc-embedded-subscribe-form").submit(function(){
gtag('event', 'play', {
'event_category': 'mailchimp',
'event_label': 'soft-lead-form'
});
console.log("ga Event Submitted");
});
I would GREATLY APPRECIATE any help. I've been through pages of documentation and, despite trying/testing multiple points in this process, I can not get the event to appear in Either Analytics or Optimize. This is a crucial piece for our marketing efforts and I very much want to make it work.
Thank you so much!
Gary
Surely the event with ga(...) you have to remove it because you are using gtag.
If you are seeing the events real time, then you need to wait for at least 24-72 hrs to get the data updated under Behaviour -> Events -> Overview.
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'
});
I've set up a new Analystics account, and copied over the tracking code. It's of the kind
<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>
I then track an event using
gtag('event', 'click', {
event_category: 'acquisition',
event_action: 'click',
event_label: 'download',
event_value: 1
});
I've tried all kinds of gtag() syntax, however nothing ever gets sent to Analytics. When checking the Network tab in Chrome debug tools, there is no communication with Google at all. (the dataLayer array is properly populated)
I don't want to use Google Tag Manager, just looking for a simple "track event via Javascript".
Looks like it is working, might be a local computer/browser addon that's blocking the call to GA