Skip to content
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.

Migrate from old to new Google Tag Manager / analytics #57

Open
nfreear opened this issue Feb 21, 2018 · 0 comments
Open

Migrate from old to new Google Tag Manager / analytics #57

nfreear opened this issue Feb 21, 2018 · 0 comments

Comments

@nfreear
Copy link
Contributor

nfreear commented Feb 21, 2018

WHY?

  • The old system uses http://...js which redirects to https://...js to embed Javascript(s).

Old

<script>
    var dataLayer = [{'gaProperty': 'UA-55775559-1'}];
</script>
<!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-K3DZ53"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<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=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-K3DZ53');</script>
<!-- End Google Tag Manager -->

New

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-55775559-1"></script>
<script>
(function (W, L) {
  W.dataLayer = W.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-55775559-1', { page_path: L.pathname + L.hash.replace('#', '/-') } );
})
(window, window.location);
</script>

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant