Expand my Community achievements bar.

Get ready! An upgraded Experience League Community experience is coming in January.
SOLVED

Adobe Target V2: Conditional Delivery Call Based on DOM Element

Avatar

Level 2

How do I enable the delivery call only when a particular section is available in the DOM?
I am using the Adobe Target V2 extension. If you need any details from me, please feel free to ask.

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @PrasanthV  Generally the delivery calls happening at the time of page loads. In case you want this to restrict based on DOM elements then you can create a Rule in Adobe Launch ( tag manager)  that checks for the presence of a DOM element before firing the Target delivery call. 

 

Like in below Rule - You can check for condition. By the way what's your use case? If you share more details ... 

 

Gokul_Agiwal_0-1762856184383.png

Hope this helps. 

View solution in original post

5 Replies

Avatar

Correct answer by
Community Advisor

Hi @PrasanthV  Generally the delivery calls happening at the time of page loads. In case you want this to restrict based on DOM elements then you can create a Rule in Adobe Launch ( tag manager)  that checks for the presence of a DOM element before firing the Target delivery call. 

 

Like in below Rule - You can check for condition. By the way what's your use case? If you share more details ... 

 

Gokul_Agiwal_0-1762856184383.png

Hope this helps. 

Avatar

Level 2

Hi @Gokul_Agiwal ,

This is my condition script, but it's not working.

var elementCheck = setInterval(function () {
  if (document.querySelectorAll('.listing-icons__header-wrapper__title.listing-icons-title.line-clamp-2').length > 1) {
    clearInterval(elementCheck);
  }
}, 100);
return false;

Avatar

Community Advisor

Hi @PrasanthV  

I did try with custom code just added document.querySelector('') with right DOM element from page and it's working for me. So when the DOM element is available then only I can see the Target is getting fired. 

 

So may I ask why you're using setInterval method here? the element you've added not present in the page initially is it the case?  Incase if element getting load later in the page then try once with setTimeout function. 

 

let me know how it goes. Thanks

Avatar

Level 2

Hi @Gokul_Agiwal 

Thank you for the lead. I have sorted it out like this.

 

PrasanthV_0-1764575276608.png

 

Avatar

Community Advisor

HI @PrasanthV 

Glad to know that its work for you now!!!