Code Monkey home page Code Monkey logo

snowplow-gtm-custom-template's Introduction

GTM Custom Template for JavaScript Tracker

Overview

This is the Google Tag Manager custom template for the Snowplow Analytics JavaScript tracker.

The Snowplow Analytics tag template lets you deploy, implement, and configure the Snowplow Analytics JS tracker on the website using Google Tag Manager.

It has been designed to be used with the Snowplow Analytics Settings custom variable template.

Quickstart

Work on the template should be done in Google Tag Manager's native template editor. This is to ensure the template has access to all the latest features of the template editor, and to make sure it passes GTM's own validation when exporting the changes.

To import the template into Google Tag Manager:

  1. In a Google Tag Manager web container (any container will do), browse to Templates and click to create a new template.
  2. From the template action menu, choose Import.
  3. Locate the template.tpl file from this repo, and import it into the template editor.

Make the changes you wish. Make sure the unit tests pass (in the Tests tab of the editor). Update the tests if necessary.

Once you're done, follow these steps:

  1. Save the template in the template editor.
  2. From the action menu, choose Export.
  3. Replace the template.tpl file in this repo with the exported file (make sure to keep template.tpl as its name)..
  4. Commit the changes to the template.tpl file.
  5. Copy the commit hash.
  6. Edit metadata.yaml in the template folder, and add the hash with its changeNotes as the latest version.
  7. Move the previous latest version into the list of Older versions.
  8. Save changes to metadata.yaml and commit them.
  9. Finally, push the changes to the repo (should include the commit to template.tpl and the commit to metadata.yaml).

After pushing the changes, Google Tag Manager should update the template in the community gallery within some hours to some days.

Find out more

Tag Template
i1
Technical Docs

Copyright and license

Significant portions copyright 2020 Simo Ahava. Remainder copyright 2020 Snowplow Analytics Ltd. All rights reserved.

Licensed under the [Apache License, Version 2.0][license] (the "License"); you may not use this software except in compliance with the License.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

snowplow-gtm-custom-template's People

Contributors

sahava avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

snowplow-gtm-custom-template's Issues

Set links in Help Text to open in new tab

The links in Help Text prompts should open in a new tab so that they do not erase the user's in-progress settings when clicked. The link in trackerName Help Text is where I first spotted this.

Template review feedback

Thanks for submitting a template to the gallery, there were a few issues in your template that needed to be resolved ahead of approving the template for the gallery.

  1. User instructions to install the template should direct users to install the gallery version of the template by clicking on the "Search Gallery" button in the template tab to add the gallery template.
  2. The documentation url shows "Page not found" error.
    Screenshot 2020-05-14 at 10 48 23 AM

Permissions: Allow storage.googleapis.com

The current permissions for google storage hosted URLs only allows storage.cloud.google.com which requires users to be authenticated with Google to access the hosted files. The public, and unauthenticated domain is: storage.googleapis.com and should be a default-enabled domain for this template.

Automatic link click tracking: Global contexts not recognized

I'm not a 100% sure if this is a template problem, but I believe it is possible to send global contexts with all kinds of Snowplow events. However when defining global contexts, I can't find any way to attach them to link_click events.

My GTM setup in order of tag sequence:

  1. addGlobalContexts
  2. pageView
  3. Link Click Tracking

I did also try to directly add the contexts via "Add Custom Contexts" but no luck either...

Fix addEnhancedEcommerceImpressionContext picking up the wrong positional arguments

I was having trouble with the addEnhancedEcommerceImpressionContext as it always was marked as invalid schema. I realized, that the Snowplow library picks up the wrong values of the Datalayer. This seems to be because of the positional arguments the SP library is requiring:

This is an impression datalayer example:

        id: 'U-30-Abo ePaper und M-Plus',
        name: 'U-30-Abo ePaper und M-Plus',
        price: '14.9900',
        brand: 'Mittelbayerische Zeitung',
        category: 'catalog/category/view/s/neukunde-digitale-angebote/id/24/',
        position: 1,
        list: 'Spezial Angebote'

This is what ends up in the Snowplow hit:

id:	U-30-Abo ePaper und M-Plus
name:	U-30-Abo ePaper und M-Plus
list:	Spezial Angebote
brand:	Mittelbayerische Zeitung
category:	catalog/category/view/s/neukunde-digitale-angebote/id/24/
variant:	1
position:	14

Position will end up as variant and part of the price will end up as position.

Fix link click tracking to include the parameter variable option

Manual link click tracking is currently the odd one out when it comes to events in the template.

Other events let you load the parameters using a variable, but manual link tracking only has the parameter table option.

Link tracking should be fixed to also allow loading the parameters from a variable.

Update injectScript permissions to have AWS S3 Cloudfront and GCP Storage by default

Currently the default permission for injectScript is the GitHub link to the Snowplow library. This is a relic of the development process, where I was loading the script from GitHub directly, knowing it would work fine with the limited use I had for the template while developing it.

However, now the link is a big problem, because modifying the permission will break the link to the gallery.

By setting the default permissions to:

https://*.cloudfront.net/*
https://storage.cloud.google.com/*

Most cases of self-hosting would likely be solved, as it is probably very common to load the dependency from these hosts.

Bundle multiple commands into a single tag

The current implementation of the template requires that every single command and hit be represented by their own tag instance. This is to give the admin command over order of execution without complicating the template itself with this logic.

However, it would make sense to offer the option of adding more than one command to the template as well as the option of having the template itself then fire a "regular" event. So you could configure a single tag to:

setUserId
enableLinkTracking
addGlobalContext
trackPageView

For example. This could be done by turning "commands" into a table, where each row represents a command and its arguments, and the order of the items in the table represents the order the commands are fired.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.