GTM - pushing events / data to gtm dataLayer not sending anything to https://www.google-analytics.com/r/collect?v
I have added this gtm code to chrome extension page (injected by content script in and iframe)
// <!-- Google Tag Manager -->
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','owDataLayer','GTM-XXXXXXX');
// <!-- End Google Tag Manager -->
I have verified that the gtm.js file has loaded successfully.
Request URL:https://www.googletagmanager.com/gtm.js?id=GTM-XXXXXX&l=dataLayer
Request Method:GET
Status Code:200 (from disk cache)
I have a button and below code was attached to the button click event
dataLayer.push({
'event': 'tab click',
'user id' : 123,
'description' : "Social"
});
When I clicked the button, the dataLayer.push worked successfully, but https://www.google-analytics.com/r/collect?
nothing was sent, https://www.google-analytics.com/r/collect?
there was no action on the Network tab of the developer toolbar window.
Can anyone help me solve this? Thank you in advance!
source to share
I spent a lot of time reading gtm and google chrome extension this weekend. Finally, I got this blog post by Simo Ahab . He discusses the same problem with a solution. Thanks Simo.
Here's a partial insert of his blog post. We need to add checkProtocolTask : false
gtm to each tag to send them from Google Chrome Extension.
Add checkProtocolTask : false
to installation fields
Scroll down to Install Fields and add a new field:
Field Name: checkProtocolTask
Value: false
Typically Google Analytics requires the request to GA to come from HTTP or HTTPS. If the requests come from somewhere else, the process is canceled. By setting a task named checkProtocolTask ββto false, we can prevent this check because the extension uses its own chrome-extension: // protocol.
Screenshot:
By doing this so that others will find this answer helps if they face the same problems. Thank!
source to share