Issue: If a customer has multiple accounts say for example,

  1. One account from Singapore region &
  2. Another 2 accounts from Mumbai region.


Now if the customer wants to track the user journey of the users from the website, all the 3 accounts tracking script has to be configured in the website.

  • Which will work fine if the customer directly places each region tracking script manually in all the pages of website!  [ But this is not feasible if the customer website has more than 100 pages]
  • But if the customer is using the GTM to install the Tracking script -> The normal of way deploying the tracking script as mentioned in this help doc will will not work for Multi-Region tracking. 


To overcome this we need to load the LeadSquared org ID with the Custom attribute called 'data-lsqoc' in the tracking script - which has to be appended in the <script> tag.


If we place tracking script directly in GTM along with the attribute name as mentioned below -> we are unable to view the same on the website i.e. attribute is not getting loaded/defined.

<!--LeadSquared Tracking Code Start-->

<script type="text/javascript" src="http://web.mxradon.com/t/Tracker.js" data-lsqoc="11350"></script>

<script type="text/javascript">

      pidTracker('11350');

</script>

<!--LeadSquared Tracking Code End-->


FYI: GTM is getting failed to load the attribute name when we are passing the attribute name directly in the script as mentioned above.


So we can load the multi-region tracking script along with the attribute name by writing the custom Javascript in the GTM as mentioned below.


Step 1: Create a new tag in the GTM by selecting the tag type as "Custom HTML Tag"  as mentioned below.


Step 2: Here we need to write the custom script to load the tracking as mentioned below.


<!--LeadSquared Tracking Code Start-->
<script type="text/javascript" src="https://web.mxradon.com/t/Tracker.js"></script>


<script type="text/javascript">
    var singaporeRegion = document.createElement('script'); // we are defing script tag
    var mumbaiRegion = document.createElement('script');

    singaporeRegion.setAttribute('data-lsqoc','11350'); // defining the attribute called 'data-lsqoc' and setting the ORG ID as value to the attribute
    mumbaiRegion.setAttribute('data-lsqoc','24778');

    singaporeRegion.setAttribute('src','https://web.mxradon.com/t/Tracker.js');       // defing the src tag with the respective region tracking URL
    mumbaiRegion.setAttribute('src','https://web-in21.mxradon.com/t/Tracker.js');

      document.head.appendChild(singaporeRegion); // Appending both src and data-lsqoc to the script tag
      document.head.appendChild(mumbaiRegion);
      setTimeout(pidTracker('24778'), 2000);     // Calling pidTracker() function with the respective ORG Id.
      setTimeout(pidTracker('11350'), 2000);
</script>
<!--LeadSquared Tracking Code End-->


Note: In the above script I am calling the pidTracker() function using the setTimeout function by giving the delay of 20 seconds to lead each region tracking - But this is not mandatory you can directly call pidTracker() function it will work fine.



FYI: Once the above multiple region tracking script is deployed - You can cross check in the customer website whether it is working fine/not by running the below mentioned command from the browser console.

leadsquared.tracker.hosts


Hope it helps, Thank you!

LeadSquared Support Team