Last active
October 28, 2020 19:43
-
-
Save THEtheChad/1380b485650eb476d90bd0350de1714a to your computer and use it in GitHub Desktop.
This file contains 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
(function (w) { | |
var uuid = 'capture_xxxxxxxx_xxxx_4xxx_yxxx_xxxxxxxxxxxx'.replace( | |
/[xy]/g, | |
function (c) { | |
var r = (Math.random() * 16) | 0, | |
v = c == 'x' ? r : (r & 0x3) | 0x8; | |
return v.toString(16); | |
} | |
); | |
w[uuid] = function (cmd, data) { | |
if (!/test/.test(cmd)) return; | |
dataLayer.push({ | |
event: 'purchase', | |
transactionId: data.id, | |
transactionTotal: data.cost, | |
transactionProducts: [] | |
}); | |
}; | |
var matches = document.body.innerHTML.match(/ga\([^)]*\)/g); | |
var i = matches.length; | |
while (i--) { | |
var match = matches[i]; | |
var code = match.replace(/^ga/, uuid); | |
eval(code); | |
} | |
})(window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment