Skip to main content

Deploying JS Attribution in Google Tag Manager (SalesForce Commerce Cloud)

Instructions for deploying your attribution tag in Google Tag Manager

Gary Garofalo avatar
Written by Gary Garofalo
Updated over a year ago

To deploy our JavaScript on SalesForce Commerce Cloud via Google Tag Manager, please follow these steps:

Before you Begin

  1. In Google Tag Manager make sure there is a trigger for a purchase or order event that is triggered on the order confirmation page

  2. Confirm there is a data layer variable for the order id that matches Salesforce Commerce Cloud's Order ID.

Implementation

  1. 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!

Did this answer your question?