Personalized checkout and custom promotions with Shopify Scripts
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!
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025