0
Fixed

Injector not injecting on sites with GTM already enabled.

James Cottrill 5 years ago updated by Supermetrics Support Team 4 years ago 10

I'm currently not able to inject onto any sites with GTM already enabled


It looks like the fix to Julius' bug has created a bug in whilst injecting on sites with GTM already enabled.

Answer

+1
Answer
Fixed

Ok - I just double checked:

  • I picked any GTM container, clicked on the Inject button, and typed stephanehamel.net
  • I opened a new browser tab and navigated to stephanehamel.net
  • The browser console says "Da Vinci Tools: Injected GTM container GTM-ABC123 - other containers are blocked."

Please do the following:

  • check if there are any errors in your browser console where a container should be injected
  • type chrome:extensions in a new browser tab, enable "Developer mode" (switch at top right of page)
  • for Da Vinci Tools, click on the "htm/background.htm" link - this will open a debugging/trace window similar to a browser debug console where you can see if there are any errors.

Let me know if you see anything special. You should see a message saying "TagManager.Inject.GTM-ABC123 set to mydomain.com" when you set it, and something like "TagManager.Inject: Blocking GTM container on page mydomain.com/page matching regex mydomain.com"

If needs be, I will do a quick screen recording session to show on it works.

Managed to submit this before I had finished typing! 

This is the error that I get when trying to inject.

The script looks like it's trying to iterate through the window rather than the dataLayer.

i is also used as the variable for the container Id, so w[l][i] passes the logic but overwrites the container Id. I've got it working with

(function(w,d,s,l,i,a){w[l]=w[l]||[];var t=!1;for(a in w[l])if(w[l][a]['event']&&w[l][a]['event']==='gtm.js'){t=true;break}if(!t)w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});const f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=!0;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f)})(window,document,'script','dataLayer','GTM-XXXXXX')

Hope that all makes sense, it did in my head!

Fixed

This was really stupid on my part - I did all the tests to make sure it was working when there was no container and didn't re-check the other scenario! :(
Fixed for next release.
There's another annoying issue so I will likely release a hot fix today.

Hi Stéphane, first thanks for all your amazing work and tool! I am trying to use Injector but even if I insert the whole domain in the inject popup It doesn't work. Is there any bug to be fixed related to this feature?

+1
Under review

Can you share what your regex looks like: is it something like "mydomain.com" or a more complex regex?

It is exactly "mydomain.com"

+1
Answer
Fixed

Ok - I just double checked:

  • I picked any GTM container, clicked on the Inject button, and typed stephanehamel.net
  • I opened a new browser tab and navigated to stephanehamel.net
  • The browser console says "Da Vinci Tools: Injected GTM container GTM-ABC123 - other containers are blocked."

Please do the following:

  • check if there are any errors in your browser console where a container should be injected
  • type chrome:extensions in a new browser tab, enable "Developer mode" (switch at top right of page)
  • for Da Vinci Tools, click on the "htm/background.htm" link - this will open a debugging/trace window similar to a browser debug console where you can see if there are any errors.

Let me know if you see anything special. You should see a message saying "TagManager.Inject.GTM-ABC123 set to mydomain.com" when you set it, and something like "TagManager.Inject: Blocking GTM container on page mydomain.com/page matching regex mydomain.com"

If needs be, I will do a quick screen recording session to show on it works.

Thanks Stéphane, works like a charme now! I deactivate AdBlock, I guess that was the problem.

Oh! Yes, that's for sure - if there's an ad blocker in the way, even your "normal" GTM container might be blocked (although most ad blockers will let GTM load but block the tags fired through it).

Thanks Stéphane, much appreciated!