Getting GTM code for a web application

Our company uses a third-party service for our career / job site, allowing users to submit job postings. Initially, users land on an external platform that blends in well with GTM. Inside the CMS, you can easily add GTM code to the header and body area. However, as soon as the user clicks “apply” in the job description, he is redirected to the web application, which is essentially a separate system. Unfortunately, this second system does not allow you to add code to the header or footer. However, I can add the code to the thank you page that users see when they submit the application.

On the thank you page, the only way to insert GTM code is to use WYSIWYG. You cannot paste code into <head> , but you can paste it into <body> . I know this is not perfect, but this is the only option.

Even if I can get the code to render on the page, it doesn't work at all. It does not record pageviews, the Google Tag Assistant does not see the code, and the Google GTM toolbar does not appear when the GTM container is in preview mode.

From what I can say, the page does not refresh when the user submits the application. So, I guess this is the reason the tag is not working. I tried using several different triggers based on the recommendations I read on the Internet, but no one solved the problem.

I just use the standard GTM code, but I will always write my code below:

  <!-- Google Tag Manager --> <script>(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','dataLayer','###');</script> <!-- End Google Tag Manager --> 

NOTE. I also use the <noscript> code immediately after the <script> code.

+5
source share
1 answer

It seems that the site you are trying to enter GTM on is taking steps to prevent you from adding JavaScript to your page.

This is a very common security measure on sites that allow users to add content to pages, because instead of GTM you can add something that attacks their server or place a bitcoin miner on this page.

https://en.wikipedia.org/wiki/Code_injection

Your only solutions to this is to ask your provider to directly support GTM, or if you are lucky you can find a version of <noscript> , and that may be enough to meet your requirements.

+1
source

Source: https://habr.com/ru/post/1273893/


All Articles