brandonmcpeak
11/16/2019 - 12:06 AM

THIS IS A GOOGLE TAG MANAGER CONTAINER FILE - for importing a tag into GTM that will asynchronously push user interaction data to the dataLa

THIS IS A GOOGLE TAG MANAGER CONTAINER FILE - for importing a tag into GTM that will asynchronously push user interaction data to the dataLayer, to do things like grab submitted email addresses.

From: https://www.bounteous.com/insights/2015/08/27/aj

{
    "exportFormatVersion": 2,
    "exportTime": "2017-05-05 19:05:42",
    "containerVersion": {
        "path": "accounts/263956808/containers/2187018/versions/0",
        "accountId": "263956808",
        "containerId": "2187018",
        "containerVersionId": "0",
        "container": {
            "path": "accounts/263956808/containers/2187018",
            "accountId": "263956808",
            "containerId": "2187018",
            "name": "jQuery AJAX Listener",
            "publicId": "GTM-NP67PS",
            "usageContext": [
                "WEB"
            ],
            "fingerprint": "1469465809950",
            "tagManagerUrl": "https://tagmanager.google.com/#/container/accounts/263956808/containers/2187018/workspaces?apiLink=container"
        },
        "tag": [
            {
                "accountId": "263956808",
                "containerId": "2187018",
                "tagId": "2",
                "name": "CU - AJAX Listener - LunaMetrics Plugin",
                "type": "html",
                "parameter": [
                    {
                        "type": "TEMPLATE",
                        "key": "html",
                        "value": "<script id=\"gtm-jq-ajax-listen\" type=\"text/javascript\">\n  (function() {\n\n    'use strict';\n\tvar $;\n    var n = 0;\n    init();\n\n    function init(n) {\n\n      // Ensure jQuery is available before anything\n      if (typeof jQuery !== 'undefined') {\n\t\t\n        // Define our $ shortcut locally\n        $ = jQuery;\n        bindToAjax();\n\n      // Check for up to 10 seconds\n      } else if (n < 20) {\n\t\n        n++;\n        setTimeout(init, 500);\n\n      }\n\n    }\n\n    function bindToAjax() {\n\n      $(document).bind('ajaxComplete', function(evt, jqXhr, opts) {\n\n        // Create a fake a element for magically simple URL parsing\n        var fullUrl = document.createElement('a');\n        fullUrl.href = opts.url;\n\n        // IE9+ strips the leading slash from a.pathname because who wants to get home on time Friday anyways\n        var pathname = fullUrl.pathname[0] === '/' ? fullUrl.pathname : '/' + fullUrl.pathname;\n        // Manually remove the leading question mark, if there is one\n        var queryString = fullUrl.search[0] === '?' ? fullUrl.search.slice(1) : fullUrl.search;\n        // Turn our params and headers into objects for easier reference\n        var queryParameters = objMap(queryString, '&', '=', true);\n        var headers = objMap(jqXhr.getAllResponseHeaders(), '\\n', ':');\n\n        // Blindly push to the dataLayer because this fires within GTM\n        dataLayer.push({\n          'event': 'ajaxComplete',\n          'attributes': {\n            // Return empty strings to prevent accidental inheritance of old data\n            'type': opts.type || '',\n            'url': fullUrl.href || '',\n            'queryParameters': queryParameters,\n            'pathname': pathname || '',\n            'hostname': fullUrl.hostname || '',\n            'protocol': fullUrl.protocol || '',\n            'fragment': fullUrl.hash || '',\n            'statusCode': jqXhr.status || '',\n            'statusText': jqXhr.statusText || '',\n            'headers': headers,\n            'timestamp': evt.timeStamp || '',\n            'contentType': opts.contentType || '',\n            // Defer to jQuery's handling of the response\n            'response': (jqXhr.responseJSON || jqXhr.responseXML || jqXhr.responseText || '')\n          }\n        });\n\n      });\n\n    }\n\n    function objMap(data, delim, spl, decode) {\n\n      var obj = {};\n\n      // If one of our parameters is missing, return an empty object\n      if (!data || !delim || !spl) {\n\n        return {};\n\n      }\n\n      var arr = data.split(delim);\n      var i;\n\n      if (arr) {\n\n        for (i = 0; i < arr.length; i++) {\n\n          // If the decode flag is present, URL decode the set\n          var item = decode ? decodeURIComponent(arr[i]) : arr[i];\n          var pair = item.split(spl);\n\n          var key = trim_(pair[0]);\n          var value = trim_(pair[1]);\n\n          if (key && value) {\n\n            obj[key] = value;\n\n          }\n\n        }\n\n      }\n\n      return obj;\n\n    }\n\n    // Basic .trim() polyfill\n    function trim_(str) {\n\n      if (str) {\n\n        return str.replace(/^[\\s\\uFEFF\\xA0]+|[\\s\\uFEFF\\xA0]+$/g, '');\n\n      }\n\n    }\n\n\n  })();\n  /*\n   * v0.1.0\n   * Created by the Google Analytics consultants at http://www.lunametrics.com\n   * Written by @notdanwilkerson\n   * Documentation: http://www.lunametrics.com/blog/2015/08/27/ajax-event-listener-google-tag-manager/\n   * Licensed under the Creative Commons 4.0 Attribution Public License\n   */\n</script>"
                    },
                    {
                        "type": "BOOLEAN",
                        "key": "supportDocumentWrite",
                        "value": "false"
                    }
                ],
                "fingerprint": "1462238923326",
                "firingTriggerId": [
                    "2147479553"
                ],
                "parentFolderId": "5",
                "tagFiringOption": "ONCE_PER_EVENT"
            }
        ],
        "variable": [
            {
                "accountId": "263956808",
                "containerId": "2187018",
                "variableId": "14",
                "name": "DLV - attributes.contentType",
                "type": "v",
                "parameter": [
                    {
                        "type": "BOOLEAN",
                        "key": "setDefaultValue",
                        "value": "false"
                    },
                    {
                        "type": "INTEGER",
                        "key": "dataLayerVersion",
                        "value": "2"
                    },
                    {
                        "type": "TEMPLATE",
                        "key": "name",
                        "value": "attributes.contentType"
                    }
                ],
                "fingerprint": "1494007864169",
                "parentFolderId": "5"
            },
            {
                "accountId": "263956808",
                "containerId": "2187018",
                "variableId": "15",
                "name": "DLV - attributes.fragment",
                "type": "v",
                "parameter": [
                    {
                        "type": "BOOLEAN",
                        "key": "setDefaultValue",
                        "value": "false"
                    },
                    {
                        "type": "INTEGER",
                        "key": "dataLayerVersion",
                        "value": "2"
                    },
                    {
                        "type": "TEMPLATE",
                        "key": "name",
                        "value": "attributes.fragment"
                    }
                ],
                "fingerprint": "1494007871817",
                "parentFolderId": "5"
            },
            {
                "accountId": "263956808",
                "containerId": "2187018",
                "variableId": "16",
                "name": "DLV - attributes.headers",
                "type": "v",
                "parameter": [
                    {
                        "type": "BOOLEAN",
                        "key": "setDefaultValue",
                        "value": "false"
                    },
                    {
                        "type": "INTEGER",
                        "key": "dataLayerVersion",
                        "value": "2"
                    },
                    {
                        "type": "TEMPLATE",
                        "key": "name",
                        "value": "attributes.headers"
                    }
                ],
                "fingerprint": "1494007880153",
                "parentFolderId": "5"
            },
            {
                "accountId": "263956808",
                "containerId": "2187018",
                "variableId": "17",
                "name": "DLV - attributes.hostname",
                "type": "v",
                "parameter": [
                    {
                        "type": "BOOLEAN",
                        "key": "setDefaultValue",
                        "value": "false"
                    },
                    {
                        "type": "INTEGER",
                        "key": "dataLayerVersion",
                        "value": "2"
                    },
                    {
                        "type": "TEMPLATE",
                        "key": "name",
                        "value": "attributes.hostname"
                    }
                ],
                "fingerprint": "1494007887171",
                "parentFolderId": "5"
            },
            {
                "accountId": "263956808",
                "containerId": "2187018",
                "variableId": "18",
                "name": "DLV - attributes.pathname",
                "type": "v",
                "parameter": [
                    {
                        "type": "BOOLEAN",
                        "key": "setDefaultValue",
                        "value": "false"
                    },
                    {
                        "type": "INTEGER",
                        "key": "dataLayerVersion",
                        "value": "2"
                    },
                    {
                        "type": "TEMPLATE",
                        "key": "name",
                        "value": "attributes.pathname"
                    }
                ],
                "fingerprint": "1494007893875",
                "parentFolderId": "5"
            },
            {
                "accountId": "263956808",
                "containerId": "2187018",
                "variableId": "19",
                "name": "DLV - attributes.protocol",
                "type": "v",
                "parameter": [
                    {
                        "type": "BOOLEAN",
                        "key": "setDefaultValue",
                        "value": "false"
                    },
                    {
                        "type": "INTEGER",
                        "key": "dataLayerVersion",
                        "value": "2"
                    },
                    {
                        "type": "TEMPLATE",
                        "key": "name",
                        "value": "attributes.protocol"
                    }
                ],
                "fingerprint": "1494007901023",
                "parentFolderId": "5"
            },
            {
                "accountId": "263956808",
                "containerId": "2187018",
                "variableId": "20",
                "name": "DLV - attributes.queryParameters",
                "type": "v",
                "parameter": [
                    {
                        "type": "BOOLEAN",
                        "key": "setDefaultValue",
                        "value": "false"
                    },
                    {
                        "type": "INTEGER",
                        "key": "dataLayerVersion",
                        "value": "2"
                    },
                    {
                        "type": "TEMPLATE",
                        "key": "name",
                        "value": "attributes.queryParameters"
                    }
                ],
                "fingerprint": "1494007907752",
                "parentFolderId": "5"
            },
            {
                "accountId": "263956808",
                "containerId": "2187018",
                "variableId": "21",
                "name": "DLV - attributes.response",
                "type": "v",
                "parameter": [
                    {
                        "type": "BOOLEAN",
                        "key": "setDefaultValue",
                        "value": "false"
                    },
                    {
                        "type": "INTEGER",
                        "key": "dataLayerVersion",
                        "value": "2"
                    },
                    {
                        "type": "TEMPLATE",
                        "key": "name",
                        "value": "attributes.response"
                    }
                ],
                "fingerprint": "1494007913848",
                "parentFolderId": "5"
            },
            {
                "accountId": "263956808",
                "containerId": "2187018",
                "variableId": "22",
                "name": "DLV - attributes.statusCode",
                "type": "v",
                "parameter": [
                    {
                        "type": "BOOLEAN",
                        "key": "setDefaultValue",
                        "value": "false"
                    },
                    {
                        "type": "INTEGER",
                        "key": "dataLayerVersion",
                        "value": "2"
                    },
                    {
                        "type": "TEMPLATE",
                        "key": "name",
                        "value": "attributes.statusCode"
                    }
                ],
                "fingerprint": "1494007919812",
                "parentFolderId": "5"
            },
            {
                "accountId": "263956808",
                "containerId": "2187018",
                "variableId": "23",
                "name": "DLV - attributes.statusText",
                "type": "v",
                "parameter": [
                    {
                        "type": "BOOLEAN",
                        "key": "setDefaultValue",
                        "value": "false"
                    },
                    {
                        "type": "INTEGER",
                        "key": "dataLayerVersion",
                        "value": "2"
                    },
                    {
                        "type": "TEMPLATE",
                        "key": "name",
                        "value": "attributes.statusText"
                    }
                ],
                "fingerprint": "1494007926744",
                "parentFolderId": "5"
            },
            {
                "accountId": "263956808",
                "containerId": "2187018",
                "variableId": "24",
                "name": "DLV - attributes.timestamp",
                "type": "v",
                "parameter": [
                    {
                        "type": "BOOLEAN",
                        "key": "setDefaultValue",
                        "value": "false"
                    },
                    {
                        "type": "INTEGER",
                        "key": "dataLayerVersion",
                        "value": "2"
                    },
                    {
                        "type": "TEMPLATE",
                        "key": "name",
                        "value": "attributes.timestamp"
                    }
                ],
                "fingerprint": "1494007932856",
                "parentFolderId": "5"
            },
            {
                "accountId": "263956808",
                "containerId": "2187018",
                "variableId": "25",
                "name": "DLV - attributes.type",
                "type": "v",
                "parameter": [
                    {
                        "type": "BOOLEAN",
                        "key": "setDefaultValue",
                        "value": "false"
                    },
                    {
                        "type": "INTEGER",
                        "key": "dataLayerVersion",
                        "value": "2"
                    },
                    {
                        "type": "TEMPLATE",
                        "key": "name",
                        "value": "attributes.type"
                    }
                ],
                "fingerprint": "1494007943093",
                "parentFolderId": "5"
            },
            {
                "accountId": "263956808",
                "containerId": "2187018",
                "variableId": "26",
                "name": "DLV - attributes.url",
                "type": "v",
                "parameter": [
                    {
                        "type": "BOOLEAN",
                        "key": "setDefaultValue",
                        "value": "false"
                    },
                    {
                        "type": "INTEGER",
                        "key": "dataLayerVersion",
                        "value": "2"
                    },
                    {
                        "type": "TEMPLATE",
                        "key": "name",
                        "value": "attributes.url"
                    }
                ],
                "fingerprint": "1494007948957",
                "parentFolderId": "5"
            }
        ],
        "folder": [
            {
                "accountId": "263956808",
                "containerId": "2187018",
                "folderId": "5",
                "name": "LunaMetrics AJAX Listener Plugin",
                "fingerprint": "1462238923317"
            }
        ],
        "fingerprint": "0",
        "tagManagerUrl": "https://tagmanager.google.com/#/versions/accounts/263956808/containers/2187018/versions/0?apiLink=version"
    }
}