How to configure a site to automatically link domains - google-analytics

Source:
https://developers.google.com/analytics/devguides/collection/gtagjs/cross-domain#configuring_a_site_to_accept_linker_parameters
Reference:
If the destination domain has been configured to automatically link domains, it will accept linker parameters by default.
I assume there is an HTML based solution for me to implement configuring a destination domain to automatically link domains.
How can I do this?

We have been using this approach. I'm not sure if it is correct, but it is an answer.
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-66686611-1', {
'linker': {
'domains': ['every.com','domain.com','that.com','I.com','will.com','link.com','to.com','or.com','from.com'],
'accept_incoming': true,
'decorate_forms': true
},
});
</script>

Related

Google analytics anonymous ip

I'm working on some wordpress sites, using the Divi theme. I have added this code in the head (Divi -> integration):
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '<GA_TRACKING_ID>', { 'anonymize_ip': true });
I have replaced '<GA_TRACKING_ID>' with the right id.
When I inspect it to see if it works, I can't find aip=1. It only says "ep.anonymize_ip: true" at the end of the Request Url and the Query String Parameter inside the collect...>.
Does this make the IP anonymous?
if you use Google Analytics 4, or the one with the code in this pattern G-XXXXXXX (instead of UA-XXXXXXX-XX), you don't have to specify the anonymize_ip since it is already active by default.

Setting Up Google Analytics For a Website

I set up a small website and added Google Analytics. I poured through a lot documentation but can't find an answer to my question. I added the Global Tag and a Tag for each individual page. I am looking to see if I need to do both as I want to track site visits and what page they view. Do I actually need both (global tag and a tag for each page) and does the setup look correct? Any assistance would be greatly appreciated.
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-171082518-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-171082518-1');
gtag('config', 'UA-171082518-1', {
'page_title' : 'Resume',
'page_path': '/#resume'
});
gtag('config', 'UA-171082518-1', {
'page_title' : 'Contact',
'page_path': '/#contact'
});
gtag('config', 'UA-171082518-1', {
'page_title' : 'About',
'page_path': '/#about'
});
The global tag must be loaded on the page the first time it opens, if the others are pages that you send on the same a page (i.e. after scroll or click) you don't need to enter it again, but if you reload the page you have to reload the initial code.
Since the site is one page and I could not use the standard analytics set up I added the following to allow me to track what section of the site a user visits.
/======== Gtag Per Section Setup ========/
$('.nav-menu a').on('click', function() {
var $this = $(this);
if($this.hasClass('activeGt')) {
return;
}
$('.nav-menu a').removeClass('activeGt');
$this.addClass('activeGt');
var page_href = $this.attr('href');
var page_title = page_href.replace('#', '');
page_title = page_title.charAt(0).toUpperCase() + page_title.slice(1) + '-Section';
var path = (window.location.href).replace(window.location.origin, '').toLowerCase();
path = path.substring(0, path.indexOf('#'));
path = path + page_href;
gtag('js', new Date());
gtag('config', 'UA-171082519-1', {
'anonymize_ip': true, // for GDPR
'page_title' : page_title,
'page_path': path
});
});

Unable to get the referrer information

I am very new in Google Analytics. I am stuck in very basic problem. Actually I have a page abc.com/ab.html . In this page there is a link of xyz.com/getref.html. on getref.html i have paste following tracking code.
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-FAKEID123"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-FAKEID123');
</script>
After clicking on the link on abc.com/ab.html it redirect me on xyz.com/getref.html . But I am not able to get the referrer information in Acquistion/All Trafic/Referrals section. It showing nothing in this section. Please Help me what could be the issue.

Cross Domain Tracking with Global Site Tag - What goes where?

Having some issues with the implementation of cross domain tracking with the Gtag.js. I'm trying to do CDT for a restaurant website which has an external booking system with a 5 different URLs (1 for each restaurant booking system). I'm using the same GA property, but have failed to figure out if the Gtag.js is set up correctly. Here's what I have on the restaurant business domain:
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXX-
1">
</script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-XXXXXXX-1', {
'linker': {
'domains' [
'https://restaurant.bookingpage1.com',
'https://restaurant.bookingpage2.com',
'https://restaurant.bookingpage3.com',
'https://restaurant.bookingpage4.com',
'https://restaurant.bookingpage5.com']
}
});
</script>
Then, on the restaurant.bookingpage1-5, I should implement:
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-
XXXXXXX-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-XXXXXXX-1', {
'linker': {
'accept_incoming': true
}
});
</script>
Afterwards, I implemented the restaurant main domain as a referral exclusion in Analytics.
Can anyone see if this is correctly set up?
You missed the colon after domains
gtag('config', 'UA-XXXXXXX-1', {
'linker': {
'domains' [

How to Mask IP addresses and Force HTTPS with Google Global Site Tag gtag.js?

How to Mask IP addresses and Force HTTPS with Google Global Site Tag gtag.js ?
In the old tracking code this is done with:
ga('set', 'forceSSL', true) //force https
ga('set', 'anonymizeIp', true) //mask ip last digits
Is this done like below in the new tracking code with gtag with { 'anonymize_ip': true }, { 'forceSSL': true} ?
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-XXXXXXXX-X', { 'anonymize_ip': true }, { 'forceSSL': true});
You should pass the pageview parameters as a JSON object:
gtag('config', 'UA-XXXXXX-X', { 'anonymize_ip': true, 'forceSSL': true });
See the Track Pageviews documentation.
There is a way closer to the analytics.js syntax and that ensures that every subsequent hits are using the same options.
You use the 'set' command before any call that fires a hit.
'set' takes an object with pairs of parameters names using lower case and '_' bewteen words instead of camelCase in analytics.js
gtag('set', { 'anonymize_ip': true, 'force_ssl': true });
gtag('config', 'UA-999999999999-99' );
See the feedback in debug mode 1 to validate your syntax and check that is it taken into account.
You can activate the debug mode with the Google Analytics Debugger Chrome extension

Resources