Replicate Google Analytics acquisition information (source, medium, GCLID, etc) as variables in Google Tag Manager.
Based on this Bounteous container.
Updated to include GCLID
See here for instructions.
Instantly share code, notes, and snippets.
Replicate Google Analytics acquisition information (source, medium, GCLID, etc) as variables in Google Tag Manager.
Based on this Bounteous container.
Updated to include GCLID
See here for instructions.
{ | |
"exportFormatVersion": 2, | |
"exportTime": "2020-09-17 18:49:20", | |
"containerVersion": { | |
"path": "accounts/4701996609/containers/32482051/versions/0", | |
"accountId": "4701996609", | |
"containerId": "32482051", | |
"containerVersionId": "0", | |
"container": { | |
"path": "accounts/4701996609/containers/32482051", | |
"accountId": "4701996609", | |
"containerId": "32482051", | |
"name": "add-clientid-to-form", | |
"publicId": "GTM-KGBF25L", | |
"usageContext": [ | |
"WEB" | |
], | |
"fingerprint": "1600349163624", | |
"tagManagerUrl": "https://tagmanager.google.com/#/container/accounts/4701996609/containers/32482051/workspaces?apiLink=container" | |
}, | |
"tag": [ | |
{ | |
"accountId": "4701996609", | |
"containerId": "32482051", | |
"tagId": "8", | |
"name": "Fill Form Client Id", | |
"type": "html", | |
"parameter": [ | |
{ | |
"type": "TEMPLATE", | |
"key": "html", | |
"value": "<script>\n var clientId = {{GA - ClientId}};\n var clientIdFields = document.querySelectorAll({{Client Id Field CSS Selector}});\n for (i = 0; i < clientIdFields.length; i++) {\n var clientIdField = clientIdFields[i];\n clientIdField.value = clientId;\n }\n</script>" | |
}, | |
{ | |
"type": "BOOLEAN", | |
"key": "supportDocumentWrite", | |
"value": "false" | |
} | |
], | |
"fingerprint": "1600357567657", | |
"firingTriggerId": [ | |
"14" | |
], | |
"parentFolderId": "3", | |
"tagFiringOption": "ONCE_PER_EVENT", | |
"monitoringMetadata": { | |
"type": "MAP" | |
} | |
} | |
], | |
"trigger": [ | |
{ | |
"accountId": "4701996609", | |
"containerId": "32482051", | |
"triggerId": "7", | |
"name": "Form Visibile", | |
"type": "ELEMENT_VISIBILITY", | |
"fingerprint": "1600368543150", | |
"parentFolderId": "3", | |
"parameter": [ | |
{ | |
"type": "BOOLEAN", | |
"key": "useOnScreenDuration", | |
"value": "false" | |
}, | |
{ | |
"type": "BOOLEAN", | |
"key": "useDomChangeListener", | |
"value": "false" | |
}, | |
{ | |
"type": "TEMPLATE", | |
"key": "elementSelector", | |
"value": "form" | |
}, | |
{ | |
"type": "TEMPLATE", | |
"key": "firingFrequency", | |
"value": "ONCE" | |
}, | |
{ | |
"type": "TEMPLATE", | |
"key": "selectorType", | |
"value": "CSS" | |
}, | |
{ | |
"type": "TEMPLATE", | |
"key": "onScreenRatio", | |
"value": "1" | |
} | |
] | |
}, | |
{ | |
"accountId": "4701996609", | |
"containerId": "32482051", | |
"triggerId": "13", | |
"name": "Window Loaded", | |
"type": "WINDOW_LOADED", | |
"fingerprint": "1600352955860", | |
"parentFolderId": "3" | |
}, | |
{ | |
"accountId": "4701996609", | |
"containerId": "32482051", | |
"triggerId": "14", | |
"name": "Form Visible and Window Loaded", | |
"type": "TRIGGER_GROUP", | |
"fingerprint": "1600352955860", | |
"parentFolderId": "3", | |
"parameter": [ | |
{ | |
"type": "LIST", | |
"key": "triggerIds", | |
"list": [ | |
{ | |
"type": "TRIGGER_REFERENCE", | |
"value": "7" | |
}, | |
{ | |
"type": "TRIGGER_REFERENCE", | |
"value": "13" | |
} | |
] | |
} | |
] | |
} | |
], | |
"variable": [ | |
{ | |
"accountId": "4701996609", | |
"containerId": "32482051", | |
"variableId": "4", | |
"name": "GA - Tracker", | |
"type": "jsm", | |
"parameter": [ | |
{ | |
"type": "TEMPLATE", | |
"key": "javascript", | |
"value": "function(){\n trackers = ga.getAll();\n return trackers[0];\n}" | |
} | |
], | |
"fingerprint": "1600350982639", | |
"parentFolderId": "3", | |
"formatValue": {} | |
}, | |
{ | |
"accountId": "4701996609", | |
"containerId": "32482051", | |
"variableId": "5", | |
"name": "GA - ClientId", | |
"type": "jsm", | |
"parameter": [ | |
{ | |
"type": "TEMPLATE", | |
"key": "javascript", | |
"value": "function(){\n gaTracker = {{GA - Tracker}};\n try {\n return gaTracker.get(\"clientId\");\n }\n catch(e){\n return false;\n }\n}" | |
} | |
], | |
"fingerprint": "1600350982639", | |
"parentFolderId": "3", | |
"formatValue": {} | |
}, | |
{ | |
"accountId": "4701996609", | |
"containerId": "32482051", | |
"variableId": "9", | |
"name": "Client Id Field CSS Selector", | |
"type": "c", | |
"parameter": [ | |
{ | |
"type": "TEMPLATE", | |
"key": "value", | |
"value": "input[name=\"client-id\"]" | |
} | |
], | |
"fingerprint": "1600353049714", | |
"parentFolderId": "3", | |
"formatValue": {} | |
} | |
], | |
"folder": [ | |
{ | |
"accountId": "4701996609", | |
"containerId": "32482051", | |
"folderId": "3", | |
"name": "Add Client ID to Form", | |
"fingerprint": "1600352939859" | |
} | |
], | |
"fingerprint": "1600368560917", | |
"tagManagerUrl": "https://tagmanager.google.com/#/versions/accounts/4701996609/containers/32482051/versions/0?apiLink=version" | |
} | |
} |