datamade / bga-payroll

💰 How much do your public officials make?
4 stars 4 forks source link

Update GA tracking codes #556

Open fgregg opened 3 years ago

fgregg commented 3 years ago

GTM Code:

Paste this code as high in the <head> of the page as possible:

    <!-- 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-KDVKMFP');</script>

    <!-- End Google Tag Manager -->

Additionally, paste this code immediately after the opening <body> tag:

    <!-- Google Tag Manager (noscript) -->

    <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-KDVKMFP"

    height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>

    <!-- End Google Tag Manager (noscript) -->

Measurement ID:G-03X4F5LNXG

you will probably need to take out the current UA-based tracking code.

fgregg commented 3 years ago

@smcalilly you should have access to the BGA properties on https://analytics.google.com

so you should be able confirm that code has gotten set up correctly.

LMK if you have any questions about this.

smcalilly commented 3 years ago

@fgregg i have two questions:

  1. will i be able to test this locally or does it need to deploy to a specific domain in order to be tracked in google analytics?
  2. you said:

    you will probably need to take out the current UA-based tracking code.

so with this change, will i also need to reconfigure the existing tracking code to work with this new tracking code?

smcalilly commented 3 years ago

i might've found an answer to question number 2. it looks like it's A Thing to migrate to google tag manager from google analytics. see this blog post and find the section Google Tag Manager vs Google Analytics: Events: https://www.analyticsmania.com/post/google-tag-manager-vs-google-analytics/

another blog post about migrating: https://threeventures.com/what-is-google-tag-manager-how-to-migrate-to-it-and-best-practices/

fgregg commented 3 years ago
  1. yes. as long as you have adtracking and privacy plugins turned off, then local browsing should trigger the events and show up in the google analytics
  2. yes, as you have found out. let me know if you need further help with this.
smcalilly commented 3 years ago

@fgregg where am i supposed to see my localhost traffic? here's a gif where i'm searching for it and not seeing it (with adblocker turned off): analytics-localhost

live site

for reference, here's a gif of me doing a similar analytic search on the live site and seeing my traffic: analytics-live-site

fgregg commented 3 years ago

do you have the same code running on staging and local?

smcalilly commented 3 years ago

i think so? locally, i'm using the latest changes from master. and not using the google tag manager code.

smcalilly commented 3 years ago

this google tag manager documentation suggests that we'll need to configure analytics in the google tag manager admin site and not google analytics. does that sound right? if so, we'll need access to the tag manager site.

fgregg commented 3 years ago

@smcalilly, i think the tags are already set up. The are in the top post: GTM-KDVKMFP

Does that work? Or are you talking about something else?

smcalilly commented 2 years ago

@fgregg yes, that works. I was looking at the wrong property in Google Analytics... I can see my traffic when I look at the "Salary" property. Should I finish the download tracking task (#551) before making a PR? That way we can test all the google analytics together and deploy it at once.

fgregg commented 2 years ago

Yes, sounds good!

On Mon, Nov 22, 2021 at 11:00 AM Sam McAlilly @.***> wrote:

@fgregg https://github.com/fgregg yes, that works. I was looking at the wrong property in Google Analytics... I can see my traffic when I look at the "Salary" property. Should I finish the download tracking task (#551 https://github.com/datamade/bga-payroll/issues/551) before making a PR? That way we can test all the google analytics together and deploy it at once.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/datamade/bga-payroll/issues/556#issuecomment-975672478, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEDC3MAX7N6QHOV6JH7JRTUNJSK5ANCNFSM5HEIAGLA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.