Personalized checkout and custom promotions with Shopify Scripts
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
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!
Solved! Go to the solution
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.
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.
Should I paste this code in collection.json or collection.list.json?
The theme is
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 %}
Okay, thanks!