Dynamically Creating Links for Multi-Site Tracking


Veracity as a company complies with GDPR to our fullest ability as such our system is built in such a way that in standard operation there is no way to attach a page load on one website to another on a different website. However, we understand some companies use multiple websites or subdomains as part of their brand or product brands.

Veracity Multi-site was created to allow a website creator to prove that the secondary website URLs are part of the same website user experience E.G looking for information on www.thisisbeacon.com and being sent to a resource on go.thisisbeacon.com to the web browser these are 2 different website to the user they are not.

As the example above www.thisisbeacon.com is not allowed to access browser information about go.thisisbeacon.com so we created a system where in beacon customers are able to say www.thisisbeacon.com and go.thisisbeacon.com are the same website this is called a website alias in the Veracity dashboard.

With this technology our system includes our multi-site tie in JavaScript that will on first load identify all links on a website and check if they are going to a website that is an alias if they are the current page load identifier is sent through to the link on the new website with a query string added to them `bcnplid={unique_id}`.

Using dynamically created links

The Multi-site plugin uses browser technology called Mutation Observer to try and identify links when they are dynamically added however this technology can still miss changes to the structure of a website by JavaScript, and there for fail to notify our system it needs to check the new links.

So the first thing to do when using dynamic links is to check to see if the technology is able to work for your setup if it’s not working for your particular set up. Our JavaScript API is there to help.

Using the JavaScript to add the unique id to your cross alias links

We have developed an example snippet of JavaScript to show how this should be correctly done 

First block of code this should go at the point of your script starting.

if(typeof window.bwai !== "undefined"){ // only do this if the tracker system is in use

window.bwai.ready(() => { // callback function once tracking system is operating correctly

window.bcnplid = window.bwai.getPageLoadId(); // save the id for use into the global scope



This would then be the code that gets used when your handling the response, please note this makes sure the bcnplid variable is set before it makes any changes so that it won’t break existing functionality.

// this block would normally go just before you set the href attribute using the url variable

if(typeof window.bcnplid !== null){

url += url.indexOf("?") > -1? // check that the url contains a question mark

'&bcnplid=${bcnplid}': // if it does we’re appending to the query string 

'?bcnplid=${bcnplid}' // if it does not we’re appending a new query string