moved GA Client ID code to JS custom GTM variable

This commit is contained in:
Cappy Popp 2021-01-06 13:21:19 -05:00
parent 0e0ffda70b
commit daea4892ad

View File

@ -4,15 +4,7 @@
iframeHolderDiv = document.createElement('div'), // so we can style location of button iframeHolderDiv = document.createElement('div'), // so we can style location of button
autoFillLocation = document.querySelector("form[id^='mktoForm_']"), // will only find first Marketo form on a page autoFillLocation = document.querySelector("form[id^='mktoForm_']"), // will only find first Marketo form on a page
firstRow = document.querySelector('form .mktoFormRow'), firstRow = document.querySelector('form .mktoFormRow'),
hiddenLinkedInInputs = document.createDocumentFragment(), // since we're creating multiple nodes, just do the add once hiddenLinkedInInputs = document.createDocumentFragment(), // since we're creating multiple nodes, just do the add once
clientID = (function () {
try {
var tracker = ga.getAll()[0];
return tracker.get('clientId'); // GA/GTM will do this same thing in customTask - see GTM customTask variable
} catch (e) {
return 'n/a';
}
})(),
hiddenInputCreator = function (tagName, onChangeHandler) { hiddenInputCreator = function (tagName, onChangeHandler) {
var newInput = document.createElement('input'); var newInput = document.createElement('input');
newInput.style.position = 'absolute'; newInput.style.position = 'absolute';
@ -321,7 +313,7 @@
values.Country, values.Country,
values.Title, values.Title,
'{{Page Path}}', '{{Page Path}}',
'gclid:' + clientID, 'gclid:' + '{{JS - GA Client ID}}',
].join(' | '), ].join(' | '),
}; };
console.log(eventData); console.log(eventData);