0

I have created chrome extension. I add google tag manager script and no script iframe in popup html like this:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Signals</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
<!-- 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','GTM-XXXXXXX');
console.log(dataLayer);
</script>
<!-- End Google Tag Manager -->

</head>
<body>

<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXXX"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
  <ch-signals maxLines="7" lang="en" symbols="rub,usd,eur"></ch-signals>


<script type="text/javascript" src="ch_signal-f9eaa1a4.js"></script></body>
</html>

All worked fine but GTM not working, i add console.log(dataLayer) in console i see dataLayer array. What is wrong?

user3804427
  • 356
  • 1
  • 9
  • If this is a popup, right-click it, then click Inspect to open its devtools window where you'll probably see an error about inline code, in which case refer to [this answer](https://stackoverflow.com/a/25721457). – wOxxOm Mar 27 '19 at 16:59
  • I added hash for inline code to manifest. I have no errors in devtools, but GTM still not working. – user3804427 Mar 28 '19 at 08:47
  • I wouldn't be surprised if it doesn't work with extensions. Try searching for existing info that either confirms or refutes that explicitly. – wOxxOm Mar 28 '19 at 08:48

1 Answers1

1

I found the answer. In the extension everything was correct, in Google Tag Manager (GTM) it was necessary to disable the protocol check. I set checkProtocolTask to false and path to {{PagePath}} in GTM fields to set, and its working now!

user3804427
  • 356
  • 1
  • 9
  • Are you sure this works? I set up GTM with your properties and I can't see data flowing... – nenadg May 19 '20 at 11:42
  • 1
    Yes, i am sure. https://chrome.google.com/webstore/detail/forex-signals/alcaiogfbpicfplnjfoghfdheaodpkme?hl=en. I created angular app and built chrome extension with GTM. – user3804427 May 20 '20 at 12:54