Dear Stape Community,
my site in production is made with Prestashop and is on the following domain:
smanique.com
I created a test environment to test stape by creating a subdomain where I cloned my site:
stg.smanique.com
I set up the server-side container following this guide:
and I configured a custom tagging URL with the following subdomain:
t.smanique.com
I changed the GTM code in the module that manages GTM and datalayer on Prestashop for UA so that it uses the subdomain t.smanique.com
:
<script data-keepinline="true">
var ajaxGetProductUrl = '//stg.smanique.com/en/module/cdc_googletagmanager/async?obj=cart-action';
/* datalayer */
dataLayer = window.dataLayer || [];
dataLayer.push({"pageCategory":"product","ecommerce":{"currencyCode":"EUR","detail":{"products":[{"name":"Afrodite - Bedazzled Stainless Steel Bracelet - Apple Watch Series 2 - 38mm and 42mm Strap","id":"365-19854","reference":"","price":"49.99","brand":"Smanique","category":"Apple Watch Series 2 - 38mm and 42mm - Bands & Straps","variant":"38mm, Gold, One Size Adjustable","link":"afrodite-bedazzled-stainless-steel-bracelet-apple-watch-series-2-38mm-and-42mm-strap","price_tax_exc":"49.99","wholesale_price":"0"}]}}});
/* call to GTM Tag */
(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://t.smanique.com/hbmlvohn.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-T289WDP');
/* async call to avoid cache system for dynamic data */
var cdcgtmreq = new XMLHttpRequest();
cdcgtmreq.onreadystatechange = function() {
if (cdcgtmreq.readyState == XMLHttpRequest.DONE ) {
if (cdcgtmreq.status == 200) {
var datalayerJs = cdcgtmreq.responseText;
try {
var datalayerObj = JSON.parse(datalayerJs);
dataLayer = dataLayer || [];
dataLayer.push(datalayerObj);
} catch(e) {
console.log("[CDCGTM] error while parsing json");
}
}
dataLayer.push({
'event': 'datalayer_ready'
});
}
};
cdcgtmreq.open("GET", "//stg.smanique.com/en/module/cdc_googletagmanager/async?obj=user" /*+ "?" + new Date().getTime()*/, true);
cdcgtmreq.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
cdcgtmreq.send();
</script>
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://t.smanique.com/ns.html?id=GTM-T289WDP"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
I set up UA server-side following this guide:
Now when I visit a stg.smanique.com
page, two collect requests are made:
- One request with domain
t.smanique.com
with status 302 which redirects tostats.g.doubleclick.net
- One request with the domain
stats.g.doubleclick.net
with status 200
Furthermore, the assistant tag detects the request sent to Google Analytics:
Metadata
Web Property ID: UA-165678681-1
Protocol version number: 1
User ID: guest_134
Could you help me figure out where Iām wrong? Thanks so much.