To deploy our JavaScript on SalesForce Commerce Cloud via Google Tag Manager, please follow these steps:
Before you Begin
In Google Tag Manager make sure there is a trigger for a purchase or order event that is triggered on the order confirmation page
Confirm there is a data layer variable for the order id that matches Salesforce Commerce Cloud's Order ID.
Implementation
Create a new tag of type "Custom HTML Tag" and in the HTML section paste:
<script>
document.addEventListener('loudcrowd-global-loaded', function() {
window.loudcrowd.init([SHOP_ID]);
window.loudcrowd.sendEvent(
'ORDER_INTAKE',
{
"order_data": {
"order_id": "{{[ORDER_ID]}}"
}
}
);
})
let script = document.createElement('script');
script.src = "https://pub.loudcrowd.com/embed.js";
script.type = module;
document.head.appendChild(script);
</script>
2. Replace [SHOP_ID] with the shop id -- the ID for your Salesforce Integration on your LoudCrowd account (If you don’t already have it then you may get it from your LoudCrowd Customer Success contact)
3. Replace [ORDER_ID] with the order id from GTM data layer (the GTM editor should autocomplete as you start typing to change the order id variable.)
4. Configure the trigger to fire with your purchase event trigger
5. Save and publish!