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 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.
npm install gtm-validator
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
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.
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
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'
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'},
...]
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' } ]
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
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
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
MIT