GithubHelp home page GithubHelp logo

carlosviniciusananias / google-tag-manager Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vtex-apps/google-tag-manager

0.0 0.0 0.0 781 KB

VTEX app that adds Google Tag Manager to a store

License: GNU Affero General Public License v3.0

TypeScript 98.91% HTML 1.09%

google-tag-manager's Introduction

📢 Use this project, contribute to it or open issues to help evolve it using Store Discussion.

Google Tag Manager

All Contributors

The VTEX Google Tag Manager (GTM) app is a first party integration to the Google Tag Manager solution.

google-tag-manager-app

Installing Google Tag Manager app

  1. Access the Apps section in your account's admin page and look for the Google Tag Manager box;
  2. Then, click on the Install button;
  3. You'll see a warning message about needing to enter the necessary configurations. Scroll down and type in your GTM ID in the Google Tag Manager field.
  4. Click on Save.

ℹ️ Info

Access the Google Tag Manager page and login to you account in order to find out what is your account GTM ID. The number your should use is the one provided by the Container ID column.

Step 2 - Creating Google Analytics variables

To set up Google Tag Manager in your store, you must create and set up all necessary variables, triggers and tags. Follow the Setting up Google Tag Manager documentation to create them.

Step 3 - Persisting campaign data throughout a user session

To prevent GTM from creating additional session identifiers every time a user navigates the website, you must add the variables originalLocation and originalReferrer to your GTM container and configure your store’s Google Analytics tags. Notice that this is important to persist campaign data throughout a user session and avoid providing inconsistent campaign data to Google Analytics (GA).

⚠️ Warning

The originalLocation and originalReferrer variables are available for VTEX IO Google Tag Manager versions 2.x and 3.x.

Creating the variables Original Location and Original Referrer

  1. Log in to your GTM account and click on the GTM container you want to work with;

gtm-container

  1. On the container page, click on Variables;

  2. In the Built-In Variables section, check if the Page URL and Page Path variables are enabled. Otherwise, click on Configure and select Page URL and Page Path to enable them;

  3. Go to the User-Defined Variables section and click on New. A side popup will open;

  4. Replace the Untitled Variable value with Original Location;

  5. Click on Variable Configuration;

  6. On Page Variables, click on Data Layer Variable;

  7. In the Data Layer Variable Name field, type originalLocation;

  8. Enable the Set Default Value option and fill in the Default Value field with the following value:

{{Page URL}}

gtm-variable-location

  1. Click on Save.

Once you have saved the originalLocation variable, create the originalReferrer as described on the steps below:

  1. In the User-Defined Variables section, click on New. A side popup will open;
  2. Replace the Untitled Variable value with Original Referrer;
  3. Click on Variable Configuration;
  4. On Page Variables, click on Data Layer Variable;
  5. In the Data Layer Variable Name field, type originalReferrer;
  6. Enable the Set Default Value option and fill in the Default Value field with the following value:
{{Referrer}}

gtm-variable-referrer

  1. Click on Save.

Updating Google Analytics Settings variables and tags

Now, let's configure every Google Analytics Settings variable that fires the originalLocation and originalReferrer variables.

  1. Go to the Variables section;
  2. On User-Defined Variables, click on the name of one of the Google Analytics Settings variables

ga-variables

  1. Click on the Variable Configuration box;
  2. Go to More Settings > Fields to Set;
  3. Click on Add Field;
  4. Set the Field Name field as location and Value as {{Original Location}};
  5. Then, click on Add Field again;
  6. Set the Field Name field as referrer and Value as {{Original Referrer}};
  7. Click on Save.

If you have any Google Analytics tags using the Google Analytics Settings variables you have changed, apply the same changes above directly on the tags that need it.

Publishing your changes

Once you have set up the Google Analytics variables and tags, follow Google's official guide on how to submit and publish your store’s container.

Restrictions

In order to avoid performance problems and unforeseen behavior, our VTEX IO Google Tag Manager solution uses the native GTM blacklist feature. You can read more about this feature on the Google Developer Guide.

We, by default, blacklist the html ID, which automatically blocklists all the tags, variables and triggers of the type customScripts. The main consequence of this blocklist is that Custom HTML tags will not be triggered.

⚠️ Warning

The HTML blacklist is VTEX Google Tag Manager app's default. If you want to disable this restriction go to https://{accountName}.myvtex.com/admin/apps/[email protected]/setup and check the toggle below.

Most of the widely used Custom HTML tags are integrations with third-party services, like Customer Chat, Analytics, Remarketing, and Pixel tags. If your store needs a Custom HTML for one of those cases, the integration can either be done by transforming the tags into a VTEX IO Pixel App or by removing this restriction.

Check out below the full list of tags and variables that are blocked, by default, in VTEX IO Google Tag Manager solution below:

Blocked tags

  • Custom HTML Tag - html
  • Eulerian Analytics Tag - ela
  • SaleCycle JavaScript Tag - scjs
  • Upsellit Global Footer Tag - uslt
  • Upsellit Confirmation Tag - uspt

Blocked variables

  • Custom JavaScript Variable - jsm

Check out a list with all the GTM available tags on the Google Developer Guide.

Contributors ✨

This project follows the all-contributors specification. Contributions of any kind are welcome!

google-tag-manager's People

Contributors

alcentu avatar andreldsa avatar brunoabreu avatar ccamargo2294 avatar cesarocampov avatar dependabot[bot] avatar gris avatar guerreirobeatriz avatar guifromrio avatar guilhermesennes avatar iaronaraujo avatar icazevedo avatar igorbrasileiro avatar jeymisson avatar jgfidelis avatar klzns avatar lucasecdb avatar lucis avatar mariana-caetano avatar rcapeto avatar victorhmp avatar vtex-io-ci-cd[bot] avatar

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.