https://gist.github.com/measureschool/f7d4cfe4e287703c6ba47ae14093e38f
MeasureSchool - ThriveCart E-commerce Events (UA & GA4)
Instructions - ThriveCart
Copy the contents from 01-base.html & paste it on
All Pagesbox in the ThriveCart Product Checkout page - ReplaceGTM-xxxxxwith your GTM container ID - Line 12.Copy the contents from 02-checkout.html & paste it on
Checkout Pagebox.Copy the contents from 03-main.html & paste it on both
One-time payment&Split payboxes
| <!-- 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-xxxxx'); //Replace this with your Container ID | |
| </script> | |
| <!-- End Google Tag Manager --> | |
| <script> | |
| if (_thrive.offer) { | |
| var dataLayer = window.dataLayer || []; | |
| dataLayer.push({ | |
| event: 'view_item', | |
| ecommerce: { | |
| items: [ | |
| { | |
| item_name: _thrive.offer.name, | |
| item_id: _thrive.offer.offer.idx, | |
| price: _thrive.offer.price / 100, | |
| item_category: _thrive.offer.type, | |
| quantity: 1, | |
| }, | |
| ], | |
| }, | |
| }); | |
| } | |
| </script> |
| <script> | |
| var dataLayer = window.dataLayer || []; | |
| var productsArray = []; | |
| var main = { | |
| name: _thrive.product.name, | |
| id: _thrive.product.idx, | |
| category: 'Main', | |
| price: _thrive.product.price, | |
| }; | |
| productsArray.push(main); | |
| var itemsArray = []; | |
| var itemInfo = { | |
| item_name: _thrive.product.name, | |
| item_id: _thrive.product.idx, | |
| item_category: 'Main', | |
| price: _thrive.product.price, | |
| quantity: 1, | |
| }; | |
| itemsArray.push(itemInfo); | |
| dataLayer.push({ | |
| event: 'view_item', | |
| ecommerce: { | |
| items: itemsArray, | |
| }, | |
| }); | |
| </script> |
| <script> | |
| var itemsArray = []; | |
| if (_thrive_order.order.bump) { | |
| var bump = { | |
| item_name: _thrive_order.order.bump.name, | |
| item_id: _thrive_order.order.bump.id, | |
| item_category: 'Bump', | |
| price: _thrive_order.order.bump.total, | |
| quantity: 1, | |
| }; | |
| itemsArray.push(bump); | |
| } | |
| if (_thrive_order.order.product) { | |
| var item = { | |
| item_name: _thrive_order.order.product.name, | |
| item_id: _thrive_order.order.product.id, | |
| item_category: 'Main', | |
| price: _thrive_order.order.product.total, | |
| quantity: 1, | |
| }; | |
| itemsArray.push(item); | |
| } | |
| if (_thrive_order.order.upsells) { | |
| for (keys in _thrive_order.order.upsells) { | |
| var item = { | |
| item_name: _thrive_order.order.upsells[keys].name, | |
| item_id: _thrive_order.order.upsells[keys].id, | |
| item_category: 'Upsell', | |
| price: _thrive_order.order.upsells[keys].total, | |
| quantity: 1, | |
| }; | |
| itemsArray.push(item); | |
| } | |
| } | |
| if (_thrive_order.order.downsells) { | |
| for (keys in _thrive_order.order.downsells) { | |
| var item = { | |
| item_name: _thrive_order.order.downsells[keys].name, | |
| item_id: _thrive_order.order.downsells[keys].id, | |
| item_category: 'Downsell', | |
| price: _thrive_order.order.downsells[keys].total, | |
| quantity: 1, | |
| }; | |
| itemsArray.push(item); | |
| } | |
| } | |
| dataLayer.push({ | |
| event: 'purchase', | |
| ecommerce: { | |
| currency: _thrive_order.order.currency, | |
| value: _thrive_order.order.total_readable, | |
| tax: _thrive_order.order.tax_readable, | |
| shipping: _thrive_order.order.shipping, | |
| affiliation: _thrive_order.order.affiliate_id, | |
| transaction_id: _thrive_order.order.invoice_id, | |
| coupon: '', | |
| items: itemsArray, | |
| }, | |
| }); | |
| </script> |
| { | |
| "exportFormatVersion": 2, | |
| "exportTime": "2023-02-28 08:54:51", | |
| "containerVersion": { | |
| "path": "accounts/144483319/containers/103506100/versions/0", | |
| "accountId": "144483319", | |
| "containerId": "103506100", | |
| "containerVersionId": "0", | |
| "container": { | |
| "path": "accounts/144483319/containers/103506100", | |
| "accountId": "144483319", | |
| "containerId": "103506100", | |
| "name": "ThriveCart GA4", | |
| "publicId": "GTM-PBXL2LJ", | |
| "usageContext": [ | |
| "WEB" | |
| ], | |
| "fingerprint": "1677573470105", | |
| "tagManagerUrl": "https://tagmanager.google.com/#/container/accounts/144483319/containers/103506100/workspaces?apiLink=container", | |
| "features": { | |
| "supportUserPermissions": true, | |
| "supportEnvironments": true, | |
| "supportWorkspaces": true, | |
| "supportGtagConfigs": false, | |
| "supportBuiltInVariables": true, | |
| "supportClients": false, | |
| "supportFolders": true, | |
| "supportTags": true, | |
| "supportTemplates": true, | |
| "supportTriggers": true, | |
| "supportVariables": true, | |
| "supportVersions": true, | |
| "supportZones": true | |
| }, | |
| "tagIds": [ | |
| "GTM-PBXL2LJ" | |
| ] | |
| }, | |
| "tag": [ | |
| { | |
| "accountId": "144483319", | |
| "containerId": "103506100", | |
| "tagId": "20", | |
| "name": "GA4 - Event - Ecommerce", | |
| "type": "gaawe", | |
| "parameter": [ | |
| { | |
| "type": "BOOLEAN", | |
| "key": "sendEcommerceData", | |
| "value": "true" | |
| }, | |
| { | |
| "type": "TEMPLATE", | |
| "key": "getEcommerceDataFrom", | |
| "value": "dataLayer" | |
| }, | |
| { | |
| "type": "TEMPLATE", | |
| "key": "eventName", | |
| "value": "{{Event}}" | |
| }, | |
| { | |
| "type": "TEMPLATE", | |
| "key": "measurementId", | |
| "value": "none" | |
| }, | |
| { | |
| "type": "TEMPLATE", | |
| "key": "measurementIdOverride", | |
| "value": "G-XXXXXXXX" | |
| } | |
| ], | |
| "fingerprint": "1677574438536", | |
| "firingTriggerId": [ | |
| "16" | |
| ], | |
| "parentFolderId": "5", | |
| "tagFiringOption": "ONCE_PER_EVENT", | |
| "monitoringMetadata": { | |
| "type": "MAP" | |
| }, | |
| "consentSettings": { | |
| "consentStatus": "NOT_SET" | |
| } | |
| } | |
| ], | |
| "trigger": [ | |
| { | |
| "accountId": "144483319", | |
| "containerId": "103506100", | |
| "triggerId": "16", | |
| "name": "custom - thrivecart ecommerce event", | |
| "type": "CUSTOM_EVENT", | |
| "customEventFilter": [ | |
| { | |
| "type": "MATCH_REGEX", | |
| "parameter": [ | |
| { | |
| "type": "TEMPLATE", | |
| "key": "arg0", | |
| "value": "{{_event}}" | |
| }, | |
| { | |
| "type": "TEMPLATE", | |
| "key": "arg1", | |
| "value": "(purchase|view_item)" | |
| } | |
| ] | |
| } | |
| ], | |
| "fingerprint": "1677574258384", | |
| "parentFolderId": "5" | |
| } | |
| ], | |
| "variable": [ | |
| { | |
| "accountId": "144483319", | |
| "containerId": "103506100", | |
| "variableId": "6", | |
| "name": "dlv - ecommerce.transaction_id", | |
| "type": "v", | |
| "parameter": [ | |
| { | |
| "type": "INTEGER", | |
| "key": "dataLayerVersion", | |
| "value": "2" | |
| }, | |
| { | |
| "type": "BOOLEAN", | |
| "key": "setDefaultValue", | |
| "value": "false" | |
| }, | |
| { | |
| "type": "TEMPLATE", | |
| "key": "name", | |
| "value": "ecommerce.transaction_id" | |
| } | |
| ], | |
| "fingerprint": "1677573843315", | |
| "parentFolderId": "5", | |
| "formatValue": {} | |
| }, | |
| { | |
| "accountId": "144483319", | |
| "containerId": "103506100", | |
| "variableId": "18", | |
| "name": "dlv - ecommerce.value", | |
| "type": "v", | |
| "parameter": [ | |
| { | |
| "type": "INTEGER", | |
| "key": "dataLayerVersion", | |
| "value": "2" | |
| }, | |
| { | |
| "type": "BOOLEAN", | |
| "key": "setDefaultValue", | |
| "value": "false" | |
| }, | |
| { | |
| "type": "TEMPLATE", | |
| "key": "name", | |
| "value": "ecommerce.value" | |
| } | |
| ], | |
| "fingerprint": "1677573843317", | |
| "parentFolderId": "5", | |
| "formatValue": {} | |
| } | |
| ], | |
| "folder": [ | |
| { | |
| "accountId": "144483319", | |
| "containerId": "103506100", | |
| "folderId": "5", | |
| "name": "ThriveCart", | |
| "fingerprint": "1677573843315" | |
| } | |
| ], | |
| "builtInVariable": [ | |
| { | |
| "accountId": "144483319", | |
| "containerId": "103506100", | |
| "type": "EVENT", | |
| "name": "Event" | |
| } | |
| ], | |
| "fingerprint": "1677574491649", | |
| "tagManagerUrl": "https://tagmanager.google.com/#/versions/accounts/144483319/containers/103506100/versions/0?apiLink=version" | |
| } | |
| } |
https://measureschool.com/set-up-thrivecart-tracking/
