Archived topic
Google conversion tag
11 replies · Started by takkularapsis on June 5, 2019
Hi,
My Google marketing provider sent me this script to be added in the head-section of the page. After i have added the code i tryid to check and still conversion alantyics isnt active...?
<!-- Global site tag (gtag.js) - Google Ads: 749550544 -->
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-749550544"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'AW-749550544');
</script>
I have added this to hooks -> wp-head ( execute php and priority set to 0 )
Do you use the correct google Analytics code?
Both of them needs to be installed for the optimize plugin to work
Hi,
I have installed google analytics via google and monsterinsights. Should i do something else?
Heres what reads in source code:
var disableStr = 'ga-disable-UA-126725762-4';
/* Function to detect opted out users */
function __gaTrackerIsOptedOut() {
return document.cookie.indexOf(disableStr + '=true') > -1;
}
/* Disable tracking if the opt-out cookie exists. */
if ( __gaTrackerIsOptedOut() ) {
window[disableStr] = true;
}
/* Opt-out function */
function __gaTrackerOptout() {
document.cookie = disableStr + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
window[disableStr] = true;
}
if ( mi_track_user ) {
(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','__gaTracker');
__gaTracker('create', 'UA-126725762-4', 'auto');
__gaTracker('set', 'forceSSL', true);
__gaTracker('send','pageview');
} else {
console.log( "Note: The site owner has disabled Google Analytics tracking for your user role." );
(function() {
/* https://developers.google.com/analytics/devguides/collection/analyticsjs/ */
var noopfn = function() {
return null;
};
var noopnullfn = function() {
return null;
};
var Tracker = function() {
return null;
};
var p = Tracker.prototype;
p.get = noopfn;
p.set = noopfn;
p.send = noopfn;
var __gaTracker = function() {
var len = arguments.length;
if ( len === 0 ) {
return;
}
var f = arguments[len-1];
if ( typeof f !== 'object' || f === null || typeof f.hitCallback !== 'function' ) {
console.log( 'Not running function __gaTracker(' + arguments[0] + " ....) because you are not being tracked. " + mi_no_track_reason );
return;
}
try {
f.hitCallback();
} catch (ex) {
}
};
__gaTracker.create = function() {
return new Tracker();
};
__gaTracker.getByName = noopnullfn;
__gaTracker.getAll = function() {
return [];
};
__gaTracker.remove = noopfn;
window['__gaTracker'] = __gaTracker;
})();
}
</script>
Hi there,
if you use the browser tools > inspect you should be able to see your scripts in the Head of the document. Which means the hook is working, can you confirm that the correct tags are being used.
If you can see it then yes the hook is working. Can you also see the Google Analytics script from Monster Insights?
Cant see it in monster insight. Maybe it is because dont have pro version of it...? But i count that it is working :)
If you're google analytics code is working, which i assume you can tell from your google analytics account then there must be something wrong with the other script you have been provided with.
I dont have any other scripts or other analytics than monster insights connected with GA. This is the script they provided me. when i put this to wp_head hook, and check with gachecker it shows global tag ok, and if i remove it and check again, it shows not ok. This is my first time adding the code to GP so there could be issue with the user here :)
<!– Global site tag (gtag.js) – Google Ads: 749550544 –>
<script async src=”https://www.googletagmanager.com/gtag/js?id=AW-749550544″></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag(‘js’, new Date());
gtag(‘config’, ‘AW-749550544’);
</script>
The code looks fine to me and is showing in the head of the document, and if the GAChecker says its ok then i can' see what the problem is.
Thank you for support!
You're welcome