mercredi 12 décembre 2018

Google Tag Manager Custom JavaScript variable AND OR regex

I am trying to do two things via a Custom JS in Google Tag Manager. This is the full code and in are other variables I call:


function () {
if ( == "https://www.google.com/" ||  == "" &&  == "https://www.example.com/" ||  == "https://www.example.com/folder" ||  == "https://www.example.com/folder/folder" &&  == "Dec" &&  == 11 &&  >= 600 &&  <= 1500) { 
  return true;
}
else {
 return false;
}
}


What I am trying to achieve is the following:

if ( == "https://www.google.com/" ||  == "" 

This code looks up for 2 Referrers. If it is Google OR if there is no Referrer (direct traffic).


Then I want to check if the Page URL equals a certain url.

&&  == "https://www.example.com/" ||  == "https://www.example.com/folder" ||  == "https://www.example.com/folder/folder" 


What I preferably want to do here is use regex do to something like this:

&&  == "https://www.example.com/"|"https://www.example.com/folder"|"https://www.example.com/folder/folder" 


I tried multiple ways to achieve this, but nothing seems to work.


This part here is workings as expected:

&&  == "Dec" &&  == 11 &&  >= 600 &&  <= 1500) { 
  return true;
}
else {
 return false;
}
}


So long story short what I want to achieve is the following:

Check if Referrer is Google OR Direct traffic AND Page URL (actually landing page) is one of the 3 described AND month & day equals the input AND the number is between a certain range.

Hopefully this is clear and someone can guide me to the best possible solution.

Thanks!

Aucun commentaire:

Enregistrer un commentaire