GTM - pushing events/data to gtm dataLayer not sending anything to https://www.google-analytics.com/r/collect?v
Asked Answered
B

1

9

I have added this gtm code in my chrome extension page(injected by the 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 confimred the gtm.js file 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 has been attached to the click event of the button

dataLayer.push({
    'event': 'tab click',
    'user id' : 123,
    'description' : "Social"
});

When I click the button dataLayer.push worked with success but nothing is being sent to https://www.google-analytics.com/r/collect? no activities in the "Network" tab of developer toolbar window.

Can anybody help me resolving this? Thanks in advance!

EDIT: Adding screenshot of the tag setup. enter image description here

Brinkema answered 4/8, 2017 at 9:9 Comment(5)
Can you share the setup of the Tag in GTM that should fire on 'tab click' event? (screenshot would be great)Glorious
@Matus, added the screenshot of the tag setup. Thanks!Brinkema
Thanks, but I meant the tag setup in your GTM account. I am not sure where are you setting up this "tag" - I've never seen this before. In any case, you need to define that this tag should fire on "tab click" event. Besically in your GTM account you need to create "Custom Event" trigger and then set the tag to fire on this trigger - have you done it?Glorious
@Matus, the above screenshot is of JSON exported from the tagmanager dashboard. Yes I have set up my tags properlyt and its working fine if I use them in website but its not working in the chrome extension.Brinkema
@Matus, FYI, I have found the solution for my problem and posted the same in my answer. Thanks for giving your time.Brinkema
B
11

I have spent a lot of time this weekend on reading gtm and Google chrome extension. Finally I got this blog post by Simo Ahava. He discussing the exact same problem with solution. Thanks to Simo.

Here is partial paste of his blog post. We must add checkProtocolTask : false to each gtm tag in order to send track them from Google Chrome Extension.

Add checkProtocolTask : false to Fields to Set

Scroll down to Fields to Set, and add a new field:

Field Name: checkProtocolTask
Value: false

Normally, Google Analytics requires that the request to GA originate from either HTTP or HTTPS. If the requests originate from anywhere else, the process is cancelled. By setting the task named checkProtocolTask to false, we can prevent this check from happening, since the extension uses the custom chrome-extension:// protocol.

Screenshot:

enter image description here

Posting this so others an find this answers helpful if they face same issues. Thanks!

Brinkema answered 8/8, 2017 at 5:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.