___TERMS_OF_SERVICE___ By creating or modifying this file you agree to Google Tag Manager's Community Template Gallery Developer Terms of Service available at https://developers.google.com/tag-manager/gallery-tos (or such other URL as Google may provide), as modified from time to time. ___INFO___ { "type": "TAG", "id": "cvt_temp_public_id", "version": 1, "securityGroups": [], "displayName": "Pandus SDK", "categories": [ "ANALYTICS", "UTILITY" ], "brand": { "id": "brand_dummy", "displayName": "" }, "description": "Adds the Pandus SDK to your site: accessibility barriers that real visitors meet, privacy-friendly analytics and e-commerce events. The script collects nothing until the visitor agrees in a consent banner.", "containerContexts": [ "WEB" ] } ___TEMPLATE_PARAMETERS___ [ { "type": "TEXT", "name": "siteKey", "displayName": "Pandus site key", "simpleValueType": true, "help": "The 24-character site key from Pandus: open your site, then SDK → Install. It identifies the site and is not a secret. The SDK accepts data only from the domains you confirmed.", "valueValidators": [ { "type": "NON_EMPTY" }, { "type": "REGEX", "args": [ "^[a-z0-9]{24}$" ], "errorMessage": "The site key is 24 lower-case letters and digits." } ] } ] ___SANDBOXED_JS_FOR_WEB_TEMPLATE___ const injectScript = require('injectScript'); const encodeUriComponent = require('encodeUriComponent'); const logToConsole = require('logToConsole'); const siteKey = data.siteKey; // The key is 24 lower-case letters and digits; anything else is not sent anywhere. if (typeof siteKey !== 'string' || !siteKey.match('^[a-z0-9]{24}$')) { logToConsole('Pandus SDK: the site key must be 24 lower-case letters and digits (SDK → Install in Pandus).'); data.gtmOnFailure(); return; } // A tag manager cannot put attributes on the script it injects, so the key travels in the // address: the loader reads ?site=. The script itself waits for the visitor's consent. injectScript( 'https://pandus.online/embed.js?site=' + encodeUriComponent(siteKey), data.gtmOnSuccess, data.gtmOnFailure, 'pandus-sdk' ); ___WEB_PERMISSIONS___ [ { "instance": { "key": { "publicId": "logging", "versionId": "1" }, "param": [ { "key": "environments", "value": { "type": 1, "string": "debug" } } ] }, "isRequired": true }, { "instance": { "key": { "publicId": "inject_script", "versionId": "1" }, "param": [ { "key": "urls", "value": { "type": 2, "listItem": [ { "type": 1, "string": "https://pandus.online/embed.js*" } ] } } ] }, "clientAnnotations": { "isEditedByUser": true }, "isRequired": true } ] ___TESTS___ scenarios: - name: Injects the Pandus script with the site key code: |- const mockData = {siteKey: 'abcdefghijklmnopqrstuvwx'}; mock('injectScript', (url, onSuccess, onFailure, cacheToken) => { assertThat(url).isEqualTo('https://pandus.online/embed.js?site=abcdefghijklmnopqrstuvwx'); assertThat(cacheToken).isEqualTo('pandus-sdk'); onSuccess(); }); runCode(mockData); assertApi('injectScript').wasCalled(); assertApi('gtmOnSuccess').wasCalled(); - name: Refuses a site key of the wrong form and loads nothing code: |- const mockData = {siteKey: 'https://evil.example/x.js'}; runCode(mockData); assertApi('injectScript').wasNotCalled(); assertApi('gtmOnFailure').wasCalled(); ___NOTES___ Created for the Pandus SDK (https://pandus.online/en/sdk). Source and issues: https://github.com/Pandus-Online/gtm-template-pandus-sdk