Solved

How can I trigger a Klaviyo pop-up on a specific collection?

mxomediaromania
Shopify Partner
6 0 0

Hello! I need some help, I need to build a custom trigger on a Klaviyo pop-up which triggers on a certain collection called "Friteuze" when someone clicks on a product. Here's the Klaviyo code:

 

<script type="text/javascript">
document.querySelector(".klaviyo_form_trigger").addEventListener('click',function (){
window._klOnsite = window._klOnsite || [];
window._klOnsite.openForm('FormID', () => console.log("you triggered the form!"));
});</script> 

 

Can anyone help me with this? Or if trigger on collection doesnt work, maybe trigger the pop-up on a certain product? 

Thanks!

 
Octav Mihai
Accepted Solution (1)

Salil17
Shopify Partner
86 5 12

This is an accepted solution.

{% if collection.handle == "winter-sale" %}
<script type="text/javascript"> document.querySelector(".klaviyo_form_trigger").addEventListener('click',function (){ window._klOnsite = window._klOnsite || []; window._klOnsite.openForm('FormID', () => console.log("you triggered the form!")); });</script> 

{% endif %}

Was my reply helpful? Please Like and Accept Solution. This mean a lot to me.

 

View solution in original post

Replies 5 (5)

Salil17
Shopify Partner
86 5 12

This is an accepted solution.

{% if collection.handle == "winter-sale" %}
<script type="text/javascript"> document.querySelector(".klaviyo_form_trigger").addEventListener('click',function (){ window._klOnsite = window._klOnsite || []; window._klOnsite.openForm('FormID', () => console.log("you triggered the form!")); });</script> 

{% endif %}

Was my reply helpful? Please Like and Accept Solution. This mean a lot to me.

 

mxomediaromania
Shopify Partner
6 0 0

Should I paste this code in collection.json or collection.list.json?

Octav Mihai
mxomediaromania
Shopify Partner
6 0 0

The theme is 

Shoptimized theme 6.23

Octav Mihai
Salil17
Shopify Partner
86 5 12

I'm not aware of the theme. If you try and test it out. 

 

{% if collection.handle == "winter-sale" %}
Add some text here - If this text is visible then on particular collection, then the code is working
{% endif %}
mxomediaromania
Shopify Partner
6 0 0

Okay, thanks!

Octav Mihai