Bonjour à tous,
Pour un client, nous devons ajouter plusieurs comptes Google Analytics sur un site (sur un compte universel analytics.js). Toutefois, nous relevons d'importantes différences de stats entre les différents comptes.
Savez-vous quelle est la meilleure manière d'ajouter ces différents comptes (UA-xxxx):
a) Multiplier les <scripts>, soit un par compte
<script type = "text/javascript" >
(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-xxxxxxx-1', 'auto');
ga('send', 'pageview');
</script>
<!-- STATS FR -->
<script type = "text/javascript" >
(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-yyyyyyyy-1', 'auto', {'name': 'frTracker'});
ga('frTracker.send', 'pageview');
</script>
b) Utiliser une fonction
(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');
c) Utiliser la fonction 'newtracker"
Google recommande https://developers.google.com/analytics/devguides/collection/analyticsjs/advanced
ga('create', 'UA-XXXX-Y', 'auto');
ga('create', 'UA-12345-6', 'auto', {'name': 'newTracker'}); // New tracker.
puis
ga('send', 'pageview');
ga('newTracker.send', 'pageview'); // Send page view for new tracker.
Auriez-vous un exemple de code qui fonctionne (en retirant le détail des UA-)?
Merci d'avance, votre aide est précieuse!
Pour un client, nous devons ajouter plusieurs comptes Google Analytics sur un site (sur un compte universel analytics.js). Toutefois, nous relevons d'importantes différences de stats entre les différents comptes.
Savez-vous quelle est la meilleure manière d'ajouter ces différents comptes (UA-xxxx):
a) Multiplier les <scripts>, soit un par compte
<script type = "text/javascript" >
(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-xxxxxxx-1', 'auto');
ga('send', 'pageview');
</script>
<!-- STATS FR -->
<script type = "text/javascript" >
(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-yyyyyyyy-1', 'auto', {'name': 'frTracker'});
ga('frTracker.send', 'pageview');
</script>
b) Utiliser une fonction
(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');
c) Utiliser la fonction 'newtracker"
Google recommande https://developers.google.com/analytics/devguides/collection/analyticsjs/advanced
ga('create', 'UA-XXXX-Y', 'auto');
ga('create', 'UA-12345-6', 'auto', {'name': 'newTracker'}); // New tracker.
puis
ga('send', 'pageview');
ga('newTracker.send', 'pageview'); // Send page view for new tracker.
Auriez-vous un exemple de code qui fonctionne (en retirant le détail des UA-)?
Merci d'avance, votre aide est précieuse!