Can gtag.js be configured to send GA4 event data to two different GA4 Measurement IDs? - google-tag-manager

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

Related

Setting setSiteSpeedSampleRate in gtag.js

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})

How to implement the Google Analytics event monitoring on a website if the standard Analytics tracking code seems not to be enough?

The website www.3dz.it is using with WordPress.
There are four languages and each one on a different domain (Italian .it, France .fr, etc.). It is in this way using WPML with the multi-domain option, since April 2018.
Up to April 2018, the events monitoring was going. For three months with the four domains, we were without data; in July we add the new analytics code so each language has an own Analytics property.
But we are still without the monitoring of the events.
Google analytics tracking code is since July 2018 set how is actually online.
<?php if(ICL_LANGUAGE_CODE=='en'){?>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-77106642-4"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-77106642-4');
</script>
<?php } elseif(ICL_LANGUAGE_CODE=='it'){?>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-77106642-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-77106642-1');
</script>
<?php } elseif(ICL_LANGUAGE_CODE=='es'){?>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-77106642-3"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-77106642-3');
</script>
<?php } elseif(ICL_LANGUAGE_CODE=='fr'){?>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-77106642-5"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-77106642-5');
</script>
<?php } ?>
Someone can tell me please how to implement the code to obtain the monitoring of the events again?
Maybe you could try to add the tracking codes on the website using Google Tag Manager? It's very easy to add multiple tracking codes into your Google Tag Manager account and only place one GTM-code to your website.
The developer notes are pretty straightforward with regarding adding event tracking to the page, for the gtag version of GA. However, I would also agree that managing your GA set-up and event tracking via Google Tag Manager would be more appropriate and scalable for your situation.
The problem was the different library of Analytics. I solved it calling google assistance. I changed the event script in the website and I modified the conversion in Analytics (event categories and actions)

Very low bounce rate in google analytic

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});

Global Site Tag (gtag) doesn't send anything

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

Google Analytics gtag.js Iframe Cross-domain Clientid issue

Our goal here is to keep Google Analytics conversion goal tracking data when we load an iframe from another domain name that we own.
We have a domain rentalbookingsoftware.com that on the free trial page: https://rentalbookingsoftware.com/free-trial-signup/ loads an iframe for our free trial installer from sidev2.info like this:
<iframe width="80%" height="500" src="https://sidev2.info/freetrialform.php"></iframe>
We are trying to keep the gtag.js clientid the same but a new session is started on the sidev2.info gtag tracking which causes the correct referrer information to be lost as you can see from the gtag recording: https://www.screencast.com/t/l5wsqUF6oAg . Both sites are using this tracking code as suggested from: https://developers.google.com/analytics/devguides/collection/gtagjs/cross-domain and I have added sidev2.info to the referrer exclusion list: https://support.google.com/analytics/answer/2795830
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-45446232-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-45446232-1', {
'linker': {
'domains': ['rentalbookingsoftware.com', 'sidev2.info']
}
});
</script>
How can we keep the clientid using gtags? I found this: https://developers.google.com/analytics/devguides/collection/analyticsjs/cross-domain but it is for analytics.js tracking, should we switch to that tracking method?

Resources