I am trying to pass a user's client_id to a form on our checkout page so that I can use it with the Measurement Protocol later. I am doing so with this script:
$(document).ready(function () {
const ga_textbox = document.querySelector("div.chkQuestions > input");
ga_textbox.value = "test";
gtag("get", "G-XXXXXXXXXX", "client_id", (client_id) => {
ga_textbox.value = client_id;
});
});
This loads the test text info the form, but not the client_id because we are not using gtag.js on our pages. We are using this Google Tag Manager snippet:
(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-XXXXXXX');
How can we get the client_id, but still use the GTM snippet on our site?