Skip to content

Instantly share code, notes, and snippets.

@clnmcgrw
clnmcgrw / bigcommerce-product-data.js
Last active August 5, 2022 16:37
Bigcommerce Conversion Tracking - Get Product Data
(function() {
//Bigcommerce doesn't provide variables for individual product info,
//so this is a hacky way to read it from the GA ecommerce script
var products = [];
var scripts = document.getElementsByTagName('script');
for (var i = 0; i < scripts.length; i++) {
if (scripts[i].innerHTML.match(/pageTracker\._addItem/)) {
var stuff = scripts[i].innerHTML.match(/_addItem\(([^\)]+)/g);
for (var c = 0; c < stuff.length; c++) {