npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gtm-validator

v1.3.1

Published

Simple tool to validate some GTM gotchas

Downloads

22

Readme

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

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