Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Survey implementation on certain pages using DTM

Bsmith320
Level 4
Level 4

I am using DTM and need to implement a survey that only opens on certain pages. I have no issue implementing the survey in DTM. The issue is, since the Rule Conditions work as "and" statements, the usage of the condition will not work. Is there a way in the custom code to use "or" statements for the pages that I want included in the survey?

Would I use something like the below code to have the survey pop on selected pages? Is there a way to do it in the conditions section in DTM?

if ((_satellite.getVar("DOI") == "10.2307/3659443") || (_satellite.getVar("DOI") == "10.2307/3061167")  || (_satellite.getVar("DOI") == "10.2307/40801588"))

1 Accepted Solution
ParitMittal
Correct answer by
Level 10
Level 10

Hi Bill,

When you are using custom code in rule conditions for a page load rule, you must use the boolean return true when you want the rule to fire.Hence As per the above requirement Please return true from the code. Also, Please make sure that the "Data Element" - "DOI" is available to be used in Custom conditions.

if ((_satellite.getVar("DOI") == "10.2307/3659443") || (_satellite.getVar("DOI") == "10.2307/3061167")  || (_satellite.getVar("DOI") == "10.2307/40801588")) { return true; } else { return false; }

Thanks & Regards

Parit Mittal

View solution in original post

5 Replies
ParitMittal
Correct answer by
Level 10
Level 10

Hi Bill,

When you are using custom code in rule conditions for a page load rule, you must use the boolean return true when you want the rule to fire.Hence As per the above requirement Please return true from the code. Also, Please make sure that the "Data Element" - "DOI" is available to be used in Custom conditions.

if ((_satellite.getVar("DOI") == "10.2307/3659443") || (_satellite.getVar("DOI") == "10.2307/3061167")  || (_satellite.getVar("DOI") == "10.2307/40801588")) { return true; } else { return false; }

Thanks & Regards

Parit Mittal

View solution in original post

Bsmith320
Level 4
Level 4

Parit,

Thank you for the update.

 

Bill

Bsmith320
Level 4
Level 4

Parit,

Here is the code that I have for my survey. Once I added the $.getScript, I was getting errors with the "return true", "else" and "return false". I think this work. I wanted to know if you think I am missing anything.

 

if ((_satellite.getVar("DOI") == "10.2307/3659443") || (_satellite.getVar("DOI") == "10.2307/3061167") || (_satellite.getVar("DOI") == "10.2307/40801588"))
 
$.getScript("//ethn.io/53363.js", function(){
  Ethnio.show()});

 

Thanks,

 

Bill

ParitMittal
Level 10
Level 10

Hi , 

Everything looks good and I assume that you are using  "return true " in the javascript file " 53363.js"  you are calling through JQuery get script function because as mentioned earlier When we use custom code in rule conditions for a page load rule, we must use the boolean return true when we want the rule to fire.

Thanks & Regards

Parit Mittal

Bsmith320
Level 4
Level 4

Parit,

 

Thank you for the feedback.

 

Bill