netlify / explorers

https://explorers.netlify.com/
MIT License
261 stars 40 forks source link

add Google Tag Manager script #277

Closed jlengstorf closed 3 years ago

jlengstorf commented 4 years ago

I don't know how Next does this, but we need to inject this at the top of every page:

<script async src="https://www.googletagmanager.com/gtag/js?id=G-GW8B862DBD"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'G-GW8B862DBD');
</script>

or we could use snippet injection?

@scottmathson

sdras commented 4 years ago

I'm currently using some snippet injection for GA, so we should check conflicts there at the very least. Thanks!

sdras commented 4 years ago

Possible to just update mine?

scottmathson commented 4 years ago

Will dig in and see what is setup in way of Analytics already, then.

@sdras did you setup a new property/view in Analytics already then, too? Just want to make sure we don't overwrite each other there.

sdras commented 4 years ago

I set up a Jamstack Explorers property, yeah. But I fully admit I could have done this wrong, so please feel free to trash mine or edit!

sdras commented 3 years ago

@scottmathson this is what I had in there, is this correct? Does it need updating? CleanShot 2020-11-13 at 15 04 24

scottmathson commented 3 years ago

@scottmathson this is what I had in there, is this correct? Does it need updating? CleanShot 2020-11-13 at 15 04 24

thanks for clarifying - I'll delete my duplicate properties then, considering you set this up (I'm seeing it in GA now).

note: we'll definitely want to update this URL to explorer.netlify.com or whatever prod one will be, at go-live. will keep as-is for now, during dev and testing phase here. admin url settings of property in ga

that tracking snippet is 100% accurate!

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

  gtag('config', 'UA-42258181-27');
</script>

we can touch-base later, but @jlengstorf and I discussed integrating googletagmanager for goals/event tracking deeper attribution and data (as we do on www.) after launch - this should be solid for launch, though! (assuming snippet is injected on every page we want tracked, etc).

scottmathson commented 3 years ago

we'll treat this as source of truth in GA, then ga jamstack explorer property

I'd say this issue good to close @jlengstorf

(https://analytics.google.com/analytics/web/#/report-home/a42258181w249070131p230965110)

sdras commented 3 years ago

Awesome