Skip to content

Add Google Tag Manager/ Google Analytics to the website and implement cross-domain tracking with the Open Database site #1132

@Lynguyen237

Description

@Lynguyen237

ISSUE: In order to track pageviews of the new Open Database site to see if people are actually using it and how they navigate, we need to add Google Analytics (GA) (property UA-165448746-1) to the new data site (https://bapd-opendb.herokuapp.com/), which is a different site from https://panda.baybrigades.org/. Cross-domain tracking is needed to not double-count users and sessions when users travel back and forth between these 2 sites

SOLUTION: The group discussed on Apr 8 and agreed with the solution to implement everything via Google Tag Manager (GTM) (including the current Google Analytics tag). Josh created the free Google Tag Manager account and gave Ly edit access to proceed with implementation.

(1) We first need to implement GTM on both sites.
(2) After that, we will implement the GA tags (pageview, clicks, or other events) via the Tag Manager UI and will deactivate ga.js plugin (https://github.com/sfbrigade/stop-covid19-sfbayarea/blob/69795e42e2486543b067328af0e7001ee73da27f/plugins/ga.js)

For (1), copy the following JavaScript and paste it as close to the opening tag as possible on every page of your website:

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

For (1) (continued), copy the following snippet and paste it immediately after the opening tag on every page of your website

<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-WS6CSZV" height="0" width="0" style="display:none;visibility:hidden"></iframe>

Describe alternatives you've considered
Implement Analytics directly without GTM - see solution 1 in the full analysis below. The optimal solution discussed above was solution 2 in the doc.

Additional context
Full analysis: https://docs.google.com/document/d/1oT7TGnkYMNTOZBP5enX7ZFH2Hayz8B4RlGMQZVq49fQ/edit
Open Database (new): https://bapd-opendb.herokuapp.com/
Main page: https://panda.baybrigades.org/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions