Triple tracker based on double tracker

Hi,
We have a solution based on the double tracker that sends the statistics to both a roll-up property and and specific property. The double tracker is located in the roll-up property tag manager.
But, for some hits in some domains, we would like to send the stats also to a third property based on a condition.
The code we have for the double tracker is as follows:

(function(p,i,w,ik) {
var g=ik.createElement(‘script’),s=ik.getElementsByTagName(‘script’)[0];
_paq.push([‘setTrackerUrl’, p]);
_paq.push([‘setSiteId’, w]);

   var secondaryTrackerUrl = 'https://sampledomain.piwik.pro/ppms.php';    
   var secondaryWebsiteId = 'ID for secondaryWebsite';
  _paq.push(['addTracker', secondaryTrackerUrl, secondaryWebsiteId]);

    g.type='text/javascript';g.async=true;g.defer=true;g.src=i;s.parentNode.insertBefore(g,s);
})('https://sampledomain.piwik.pro/ppms.php','https://sampledomain.containers.piwik.pro/ppms.js',{{ sites ID lookuptble }},document);

How should we proceed to include a third tracker based on a condition?

Thank you!
Itziar

Hi @imartinez,

You can simply add an if statement with your condition -

(function(p,i,w,ik) {
var g=ik.createElement(‘script’),s=ik.getElementsByTagName(‘script’)[0];
_paq.push([‘setTrackerUrl’, p]);
_paq.push([‘setSiteId’, w]);

   var secondaryTrackerUrl = 'https://sampledomain.piwik.pro/ppms.php';    
   var secondaryWebsiteId = 'ID for secondaryWebsite';
  _paq.push(['addTracker', secondaryTrackerUrl, secondaryWebsiteId]);

   var thirdTrackerUrl = 'https://sampledomain.piwik.pro/ppms.php';    
   var thirdWebsiteId = 'third website ID';

if(your condition) {
_paq.push(['addTracker', thirdTrackerUrl, thirdWebsiteId]);
}
    
g.type='text/javascript';g.async=true;g.defer=true;g.src=i;s.parentNode.insertBefore(g,s);
})('https://sampledomain.piwik.pro/ppms.php','https://sampledomain.containers.piwik.pro/ppms.js',{{ sites ID lookuptble }},document);
1 Like