Tracking a Page with Multiple Google Analytics Accounts - google-analytics

I used to be able to use two different Google Analytics accounts on a single page with the old ga.js.
This is how I used to do it:
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-22766576-1']);
_gaq.push(['_trackPageview']);
_gaq.push(['_setAccount', 'UA-OTHER-ID-1']);
_gaq.push(['_trackPageview']);
...
Google Analytics now defaults to use tag manager's gtag.js and looks like this:
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-74053665-19"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-74053665-19');
</script>
The UA id is embeded in the JS call as well as in the config. It doesn't look like it's possible to fire two visits for two separate accounts anymore. Does anyone have any other solutions?

Related

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)

Real-time overview shows numbers. Audience overview – not

While I see some numbers on the "Real-Time overview" page, I don't see the pageviews / sessions data in "Audience overview" on my website. I'm having a hard times understanding why.
The website is: https://everyelixirvideo.page/. It's a single-page website with no custom javascript. This is the current tracking code:
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-33420511-4"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-33420511-4');
gtag('config', 'UA-33420511-4', {'page_path': "/"});
</script>
What am I missing?
Here are the screenshot of "Real-Time overview" and "Audience overview" pages:
good:
not good:

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.

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' [

Google Analytics Cross Domain E-Commerce Campaign Tracking

I want to track e-Commerce related stuff with Google Analytics in relation to campaigns.
The basket/checkout (included via iframe) is on a different domain than the shop.
I've enabled e-commerce tracking in GA, added tracking scripts to both pages and I get a lot of data but it seems that the campaign information gets lost, because all e-commerce data has only "shop.com / referral" as source/medium and not "campaign1/newsletter" as I would expect.
Example:
Script on shop.com:
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxx']);
_gaq.push(['_trackPageview']);
_gaq.push(['_setDomainName', 'shop.com']);
_gaq.push(['_setAllowLinker', true]);
...
Enter the site via
http://shop.com/page.html?utm_campaign=campaign1&utm_source=newsletter...
Get iframe src
via _gat._getTrackerByName()._getLinkerUrl('http://basket.com/page.html')
which returns something like
http://basket.com/page.html?__utma=14776951xxx&__utmb=14776xx..
Embed iframe with this url..
On basket.com/page.html I've added the following GA E-Commerce tracking code
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxx']);
_gaq.push(['_trackPageview']);
_gaq.push(['_setDomainName', 'basket.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_addTrans',
'1234', // transaction ID - required
'Name',
'123.4' .....
_gaq.push(['_addItem', ...
_gaq.push(['_trackTrans']);..
The really strange thing is, that even the tracking pixel (which is loaded in the iframe to track e-commerce events) seems to be correct
http://stats.g.doubleclick.net/__utm.gif?utmwv=5.4.4dc&....%3Futm_source%3Dnewsletter2%26utm_campaign%3Dcampaign1...
Did i miss something?
Thanks a lot
Try to use the _getLinkerUrl() method to pass the cookies data to the iframe.
_gaq.push(function() {
var pageTracker = _gat._getTrackerByName();
var iframe = document.getElementById('myIFrame');
iframe.src = pageTracker._getLinkerUrl('http://www.my-example-iframecontent.com/');
});
You can find full details here --> Tracking Across iFrames
... and here --> Tracking Across Multiple Domains and Sub-domains
Hope it helps.

Resources