Created
March 1, 2017 18:09
-
-
Save ju1/6fb3294d28a1461e647349c69a4e30e3 to your computer and use it in GitHub Desktop.
Copy Text To Clipboard Recipe for Google Tag Manager
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"exportFormatVersion": 2, | |
"exportTime": "2017-03-01 18:09:09", | |
"containerVersion": { | |
"path": "accounts/1164259306/containers/6439668/versions/0", | |
"accountId": "1164259306", | |
"containerId": "6439668", | |
"containerVersionId": "0", | |
"container": { | |
"path": "accounts/1164259306/containers/6439668", | |
"accountId": "1164259306", | |
"containerId": "6439668", | |
"name": "Copy Text Recipe", | |
"publicId": "GTM-MBFXPBX", | |
"usageContext": [ | |
"WEB" | |
], | |
"fingerprint": "1488391631623", | |
"tagManagerUrl": "https://tagmanager.google.com/#/container/accounts/1164259306/containers/6439668/workspaces?apiLink=container" | |
}, | |
"tag": [ | |
{ | |
"accountId": "1164259306", | |
"containerId": "6439668", | |
"tagId": "2", | |
"name": "GA - Event - Copied Text To Clipboard", | |
"type": "ua", | |
"parameter": [ | |
{ | |
"type": "BOOLEAN", | |
"key": "nonInteraction", | |
"value": "false" | |
}, | |
{ | |
"type": "BOOLEAN", | |
"key": "doubleClick", | |
"value": "false" | |
}, | |
{ | |
"type": "BOOLEAN", | |
"key": "setTrackerName", | |
"value": "false" | |
}, | |
{ | |
"type": "BOOLEAN", | |
"key": "useDebugVersion", | |
"value": "false" | |
}, | |
{ | |
"type": "TEMPLATE", | |
"key": "eventCategory", | |
"value": "Text Copied To Clipboard" | |
}, | |
{ | |
"type": "TEMPLATE", | |
"key": "trackType", | |
"value": "TRACK_EVENT" | |
}, | |
{ | |
"type": "BOOLEAN", | |
"key": "enableLinkId", | |
"value": "false" | |
}, | |
{ | |
"type": "TEMPLATE", | |
"key": "eventAction", | |
"value": "{{Page Path}}" | |
}, | |
{ | |
"type": "TEMPLATE", | |
"key": "eventLabel", | |
"value": "Text copied: {{dlv - clipboardText}}" | |
}, | |
{ | |
"type": "BOOLEAN", | |
"key": "enableEcommerce", | |
"value": "false" | |
}, | |
{ | |
"type": "TEMPLATE", | |
"key": "trackingId", | |
"value": "{{YOUR_GA_TRACKING_ID}}" | |
} | |
], | |
"fingerprint": "1488391708290", | |
"firingTriggerId": [ | |
"7" | |
], | |
"tagFiringOption": "ONCE_PER_EVENT" | |
}, | |
{ | |
"accountId": "1164259306", | |
"containerId": "6439668", | |
"tagId": "1", | |
"name": "cHTML - Copy Text Listener", | |
"type": "html", | |
"parameter": [ | |
{ | |
"type": "TEMPLATE", | |
"key": "html", | |
"value": "<script>\n// Declare function to get selected text from document\nfunction getSelectionText() {\nvar text = '';\nif (window.getSelection) {\ntext = window.getSelection().toString();\n} else if (document.selection && document.selection.type != 'Control') {\ntext = document.selection.createRange().text;\n}\nreturn text;\n}\n\n// Declare function on copy event\ndocument.addEventListener(\"copy\", function(e){\ndataLayer.push({\n'event': 'textCopied',\n'clipboardText': getSelectionText(),\n'clipboardLength': getSelectionText().length\n});\n});\n</script>" | |
}, | |
{ | |
"type": "BOOLEAN", | |
"key": "supportDocumentWrite", | |
"value": "false" | |
} | |
], | |
"fingerprint": "1488391384577", | |
"firingTriggerId": [ | |
"6" | |
], | |
"tagFiringOption": "ONCE_PER_EVENT" | |
} | |
], | |
"trigger": [ | |
{ | |
"accountId": "1164259306", | |
"containerId": "6439668", | |
"triggerId": "7", | |
"name": "Custom - Text Copied", | |
"type": "CUSTOM_EVENT", | |
"customEventFilter": [ | |
{ | |
"type": "EQUALS", | |
"parameter": [ | |
{ | |
"type": "TEMPLATE", | |
"key": "arg0", | |
"value": "{{_event}}" | |
}, | |
{ | |
"type": "TEMPLATE", | |
"key": "arg1", | |
"value": "textCopied" | |
} | |
] | |
} | |
], | |
"fingerprint": "1488391525617" | |
}, | |
{ | |
"accountId": "1164259306", | |
"containerId": "6439668", | |
"triggerId": "6", | |
"name": "Pageview - DOM ready", | |
"type": "DOM_READY", | |
"fingerprint": "1488391373278" | |
} | |
], | |
"variable": [ | |
{ | |
"accountId": "1164259306", | |
"containerId": "6439668", | |
"variableId": "1", | |
"name": "dlv - clipboardText", | |
"type": "v", | |
"parameter": [ | |
{ | |
"type": "INTEGER", | |
"key": "dataLayerVersion", | |
"value": "2" | |
}, | |
{ | |
"type": "BOOLEAN", | |
"key": "setDefaultValue", | |
"value": "false" | |
}, | |
{ | |
"type": "TEMPLATE", | |
"key": "name", | |
"value": "clipboardText" | |
} | |
], | |
"fingerprint": "1488391479053" | |
} | |
], | |
"builtInVariable": [ | |
{ | |
"accountId": "1164259306", | |
"containerId": "6439668", | |
"type": "PAGE_URL", | |
"name": "Page URL" | |
}, | |
{ | |
"accountId": "1164259306", | |
"containerId": "6439668", | |
"type": "PAGE_HOSTNAME", | |
"name": "Page Hostname" | |
}, | |
{ | |
"accountId": "1164259306", | |
"containerId": "6439668", | |
"type": "PAGE_PATH", | |
"name": "Page Path" | |
}, | |
{ | |
"accountId": "1164259306", | |
"containerId": "6439668", | |
"type": "REFERRER", | |
"name": "Referrer" | |
}, | |
{ | |
"accountId": "1164259306", | |
"containerId": "6439668", | |
"type": "EVENT", | |
"name": "Event" | |
} | |
], | |
"fingerprint": "0", | |
"tagManagerUrl": "https://tagmanager.google.com/#/versions/accounts/1164259306/containers/6439668/versions/0?apiLink=version" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment