Git Product home page Git Product logo

gtm-validator's Introduction

GTM Containers validator tool

Allows to check GTM tags against some common pitfalls that might disappoint your happy customers.

Checks can be done against local files (exported JSON containers) or directly with Google tagmanager API

WEB version

Web version lacks full functionality yet, but can be used as:

node web.js

It is also available online at: https://gtm-validator.herokuapp.com No information is being stored on the server: access_token is being stored in cookies and all data is being fetched through google api on each request.


Installation

npm install gtm-validator

Export your container as json

In GTM go to Administration > Export Container and choose container to export. Save it in the containers folder or anywhere else.

    node gtm-validator.js local path/to/exportedGTM.json

Validators

Implemented validators:

  • document.write
  • http:// links

Checks against all HTML/Script parameters and detects document.write() usage without documentWriteSupport enabled

Fixes would need to be done manually by clicking on a tag link

Use -v or --verbose mode to output tag HTML/script.

Use -s or --summary to display only resulting warnings count instead of tag info.

TagManager API

With the first api call, OAuth token would be requested. URL should be opened in browser and then code should be entered in console prompt

https://developers.google.com/tag-manager/api/v1/reference/accounts/containers/tags/update

Obtain API keys:

Go to https://console.developers.google.com/home/dashboard and create a new application, or use existing one. Be sure to add TagManager API support in Enabled APIs

Generate new OAuth keys and export them in your environment, so the application could use them:

export GAPI_CLIENT_ID='your-client-id'
export GAPI_CLIENT_SECRET='your-client-secret'

List available accounts

To get the list of all available to authorized user accounts

node gtm-validator gtm:list-accounts

[{ account: '111111', name: 'de.your-website.com'},
    { account: '222222', name: 'uk.your-website.com'},
    ...]

List account containers

To get the list of all containers within account

node gtm-validator.js gtm:list-containers 11111111

[ { accountId: '1111111',
    containerId: '2222222',
    name: 'de.your-website.com',
    publicId: 'GTM-NE444YYY',
    timeZoneCountryId: 'US',
    timeZoneId: 'America/Los_Angeles',
    notes: '',
    usageContext: [ 'web' ],
    enabledBuiltInVariable:
    [ 'pageUrl',
        'pageHostname',
        'pagePath',
        'referrer',
        'event',
        'clickElement',
        'clickClasses',
        'clickId',
        'clickTarget',
        'clickUrl',
        'clickText',
        'formId' ],
        fingerprint: '1451386358233' } ]

Validate specific container

To run validations against single container's tags

node gtm-validator.js gtm:container 11111 22222

image on documents page                 https://tagmanager.google.com/#/container/accounts/123098056/containers/1537360/tags/5
type:html   DocWrite [0] disabled   http links [0]

script alert                            https://tagmanager.google.com/#/container/accounts/123098056/containers/1537360/tags/7
type:html   DocWrite [0] disabled   http links [0]

Applicata pixel                         https://tagmanager.google.com/#/container/accounts/123098056/containers/1537360/tags/8
type:html   DocWrite [0] disabled   http links [0]


Total: 3
Warnings: 0

Validate all containers for account

To validate all containers within one account

node gtm-validator.js gtm:account <accountId>

Found 1 container(s)

GTM-ASD1234S: uk-stage.your-site.com

image on documents page                 https://tagmanager.google.com/#/container/accounts/111111/containers/22222/tags/5
type:html   DocWrite [0] disabled   http links [0]

script alert                            https://tagmanager.google.com/#/container/accounts/111111/containers/22222/tags/7
type:html   DocWrite [0] disabled   http links [0]

Applicata pixel                         https://tagmanager.google.com/#/container/accounts/111111/containers/22222/tags/8
type:html   DocWrite [0] disabled   http links [0]


Total: 3
Warnings: 0

Validate ALL

This command will find all accounts that belong to user, fetch all containers and validate every tag for every container of each account.

node gtm-validator gtm:all

AccountId: #3333   GTM-XX33YY your.website.com

.....

Total: 0
Warnings: 0

License

MIT

gtm-validator's People

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.