Skip to content

Instantly share code, notes, and snippets.

@measureschool measureschool/All Pages Tracking Code Secret
Last active Aug 29, 2019

Embed
What would you like to do?
Thrivecart GTM + DataLayer integration (change GTM ID)
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXX');</script>
<!-- End Google Tag Manager -->
<script>
if(_thrive.offer){
var dataLayer = window.dataLayer || [];
dataLayer.push({
'event': _thrive.offer.type,
'ecommerce': {
'detail': {
'products': [{
'name': _thrive.offer.name,
'id': _thrive.offer.offer.id,
'price': _thrive.offer.price/100,
'category': _thrive.offer.type
}]
}
}
});
}
</script>
<script>
var dataLayer = window.dataLayer || [];
var productsArray = []
if(_thrive.product.bump_price){
var bump = {
'name': "Bump Product",
'price': _thrive.product.bump_price,
'category': "Main"
}
productsArray.push(bump);
}
var main = {
'name': _thrive.product.name,
'price': _thrive.product.price,
'category': "Main"
}
productsArray.push(main);
dataLayer.push({
'event': 'checkout',
'ecommerce': {
'detail': {
'products': productsArray
}
}
});
</script>
<script>
var products = [];
if (_thrive_order.order.bump) {
var bump = {
'name': _thrive_order.order.bump.name,
'price': _thrive_order.order.bump.total,
'quantity': 1
}
products.push(bump);
}
if (_thrive_order.order.product) {
var product = {
'name': _thrive_order.order.product.name,
'price': _thrive_order.order.product.total,
'quantity': 1
}
products.push(product);
}
if (_thrive_order.order.upsells) {
for(keys in _thrive_order.order.upsells){
var product = {
'name': _thrive_order.order.upsells[keys].name,
'price': _thrive_order.order.upsells[keys].total,
'quantity': 1
}
products.push(product);
}
}
if (_thrive_order.order.downsells) {
for(keys in _thrive_order.order.downsells){
var product = {
'name': _thrive_order.order.downsells[keys].name,
'price': _thrive_order.order.downsells[keys].total,
'quantity': 1
}
products.push(product);
}
}
var dataLayer = window.dataLayer || [];
dataLayer.push({
'event': 'purchase',
'ecommerce': {
'purchase': {
'actionField': {
'id': _thrive_order.order.invoice_id,
'affiliation': '',
'revenue': _thrive_order.order.total,
'tax': _thrive_order.order.tax,
'shipping': _thrive_order.order.shipping,
'discount': '0.00',
'coupon': ''
},
'products': products
}
}
});
</script>
{
"exportFormatVersion": 2,
"exportTime": "2019-08-02 12:07:42",
"containerVersion": {
"path": "accounts/144483319/containers/12553716/versions/0",
"accountId": "144483319",
"containerId": "12553716",
"containerVersionId": "0",
"container": {
"path": "accounts/144483319/containers/12553716",
"accountId": "144483319",
"containerId": "12553716",
"name": "269ThriveCart",
"publicId": "GTM-KTGNTSZ",
"usageContext": [
"WEB"
],
"fingerprint": "1564746777901",
"tagManagerUrl": "https://tagmanager.google.com/#/container/accounts/144483319/containers/12553716/workspaces?apiLink=container"
},
"tag": [
{
"accountId": "144483319",
"containerId": "12553716",
"tagId": "3",
"name": "Fb - Event - Purchase",
"type": "html",
"parameter": [
{
"type": "TEMPLATE",
"key": "html",
"value": "<!-- Facebook Pixel Code -->\n<script>\n !function(f,b,e,v,n,t,s)\n {if(f.fbq)return;n=f.fbq=function(){n.callMethod?\n n.callMethod.apply(n,arguments):n.queue.push(arguments)};\n if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';\n n.queue=[];t=b.createElement(e);t.async=!0;\n t.src=v;s=b.getElementsByTagName(e)[0];\n s.parentNode.insertBefore(t,s)}(window, document,'script',\n 'https://connect.facebook.net/en_US/fbevents.js');\n fbq('init', '664776376931111');\n fbq('track', 'Purchase', {\n value: {{dlv - revenue}},\n });\n</script>\n<noscript><img height=\"1\" width=\"1\" style=\"display:none\"\n src=\"https://www.facebook.com/tr?id=664776376930868&ev=PageView&noscript=1\"\n/></noscript>\n<!-- End Facebook Pixel Code -->"
},
{
"type": "BOOLEAN",
"key": "supportDocumentWrite",
"value": "false"
}
],
"fingerprint": "1564746756567",
"firingTriggerId": [
"7"
],
"tagFiringOption": "ONCE_PER_EVENT",
"monitoringMetadata": {
"type": "MAP"
}
},
{
"accountId": "144483319",
"containerId": "12553716",
"tagId": "2",
"name": "GA - Event - Enhanced Ecommerce",
"type": "ua",
"parameter": [
{
"type": "BOOLEAN",
"key": "nonInteraction",
"value": "true"
},
{
"type": "BOOLEAN",
"key": "overrideGaSettings",
"value": "true"
},
{
"type": "BOOLEAN",
"key": "useEcommerceDataLayer",
"value": "true"
},
{
"type": "TEMPLATE",
"key": "eventCategory",
"value": "Enhanced Ecommerce"
},
{
"type": "TEMPLATE",
"key": "trackType",
"value": "TRACK_EVENT"
},
{
"type": "TEMPLATE",
"key": "gaSettings",
"value": "{{UA-1234567-1}}"
},
{
"type": "TEMPLATE",
"key": "eventAction",
"value": "{{Event}}"
},
{
"type": "BOOLEAN",
"key": "enableEcommerce",
"value": "true"
}
],
"fingerprint": "1564725427575",
"firingTriggerId": [
"6"
],
"tagFiringOption": "ONCE_PER_EVENT",
"monitoringMetadata": {
"type": "MAP"
}
},
{
"accountId": "144483319",
"containerId": "12553716",
"tagId": "1",
"name": "GA - Pageview - All Pages",
"type": "ua",
"parameter": [
{
"type": "BOOLEAN",
"key": "overrideGaSettings",
"value": "false"
},
{
"type": "TEMPLATE",
"key": "trackType",
"value": "TRACK_PAGEVIEW"
},
{
"type": "TEMPLATE",
"key": "gaSettings",
"value": "{{UA-1234567-1}}"
}
],
"fingerprint": "1564575249929",
"firingTriggerId": [
"2147479553"
],
"tagFiringOption": "ONCE_PER_EVENT",
"monitoringMetadata": {
"type": "MAP"
}
},
{
"accountId": "144483319",
"containerId": "12553716",
"tagId": "4",
"name": "GAds - Conversion - Purchase",
"type": "awct",
"parameter": [
{
"type": "BOOLEAN",
"key": "enableConversionLinker",
"value": "true"
},
{
"type": "TEMPLATE",
"key": "orderId",
"value": "{{dlv - transactionID}}"
},
{
"type": "TEMPLATE",
"key": "conversionValue",
"value": "{{dlv - revenue}}"
},
{
"type": "TEMPLATE",
"key": "conversionCookiePrefix",
"value": "_gcl"
},
{
"type": "TEMPLATE",
"key": "conversionId",
"value": "123"
},
{
"type": "TEMPLATE",
"key": "conversionLabel",
"value": "123"
}
],
"fingerprint": "1564746763759",
"firingTriggerId": [
"7"
],
"tagFiringOption": "ONCE_PER_EVENT",
"monitoringMetadata": {
"type": "MAP"
}
}
],
"trigger": [
{
"accountId": "144483319",
"containerId": "12553716",
"triggerId": "6",
"name": "custom - EE events",
"type": "CUSTOM_EVENT",
"customEventFilter": [
{
"type": "MATCH_REGEX",
"parameter": [
{
"type": "TEMPLATE",
"key": "arg0",
"value": "{{_event}}"
},
{
"type": "TEMPLATE",
"key": "arg1",
"value": "(checkout|upsell|downsell|purchase)"
}
]
}
],
"fingerprint": "1564575360198"
},
{
"accountId": "144483319",
"containerId": "12553716",
"triggerId": "7",
"name": "custom - purchase",
"type": "CUSTOM_EVENT",
"customEventFilter": [
{
"type": "EQUALS",
"parameter": [
{
"type": "TEMPLATE",
"key": "arg0",
"value": "{{_event}}"
},
{
"type": "TEMPLATE",
"key": "arg1",
"value": "purchase"
}
]
}
],
"fingerprint": "1564736038394"
}
],
"variable": [
{
"accountId": "144483319",
"containerId": "12553716",
"variableId": "1",
"name": "UA-1234567-1",
"type": "gas",
"parameter": [
{
"type": "TEMPLATE",
"key": "cookieDomain",
"value": "auto"
},
{
"type": "BOOLEAN",
"key": "doubleClick",
"value": "false"
},
{
"type": "BOOLEAN",
"key": "setTrackerName",
"value": "false"
},
{
"type": "BOOLEAN",
"key": "useDebugVersion",
"value": "false"
},
{
"type": "BOOLEAN",
"key": "useHashAutoLink",
"value": "false"
},
{
"type": "BOOLEAN",
"key": "decorateFormsAutoLink",
"value": "false"
},
{
"type": "BOOLEAN",
"key": "enableLinkId",
"value": "false"
},
{
"type": "BOOLEAN",
"key": "enableEcommerce",
"value": "false"
},
{
"type": "TEMPLATE",
"key": "trackingId",
"value": "UA-1234567-1"
}
],
"fingerprint": "1564575246710"
},
{
"accountId": "144483319",
"containerId": "12553716",
"variableId": "3",
"name": "dlv - revenue",
"type": "v",
"parameter": [
{
"type": "INTEGER",
"key": "dataLayerVersion",
"value": "2"
},
{
"type": "BOOLEAN",
"key": "setDefaultValue",
"value": "false"
},
{
"type": "TEMPLATE",
"key": "name",
"value": "ecommerce.purchase.actionField.revenue"
}
],
"fingerprint": "1564736392794",
"formatValue": {}
},
{
"accountId": "144483319",
"containerId": "12553716",
"variableId": "2",
"name": "dlv - transactionID",
"type": "v",
"parameter": [
{
"type": "INTEGER",
"key": "dataLayerVersion",
"value": "2"
},
{
"type": "BOOLEAN",
"key": "setDefaultValue",
"value": "false"
},
{
"type": "TEMPLATE",
"key": "name",
"value": "ecommerce.purchase.actionField.id"
}
],
"fingerprint": "1564735796638",
"formatValue": {}
}
],
"builtInVariable": [
{
"accountId": "144483319",
"containerId": "12553716",
"type": "PAGE_URL",
"name": "Page URL"
},
{
"accountId": "144483319",
"containerId": "12553716",
"type": "PAGE_HOSTNAME",
"name": "Page Hostname"
},
{
"accountId": "144483319",
"containerId": "12553716",
"type": "PAGE_PATH",
"name": "Page Path"
},
{
"accountId": "144483319",
"containerId": "12553716",
"type": "REFERRER",
"name": "Referrer"
},
{
"accountId": "144483319",
"containerId": "12553716",
"type": "EVENT",
"name": "Event"
}
],
"fingerprint": "0",
"tagManagerUrl": "https://tagmanager.google.com/#/versions/accounts/144483319/containers/12553716/versions/0?apiLink=version"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.