Lightspeed

A guide to implement Criteo solutions in Lightspeed.

Overview

This tutorial will explain how to install the Criteo OneTag on your Lightspeed site.

[[disclaimer-nonplugin]]

Feed

  • Go to SYSTEM > Settings > WBSITE SETTINGS > Feeds > Google Base
  • Copy the feed URL from there. Example: https://www.yourwebsiteurl.com/feed/googlebase

Tags

  • Go to Design > Theme Editor 1

  • Your Criteo account ID should be {{accountid}}

  • Edit the custom.rain file and copy the following code provided
<!-- CRITEO START -->
<script type="text/javascript" src="//static.criteo.net/js/ld/ld.js" async="true"></script>
<script type="text/javascript">
console.log("{{template}}");
window.criteo_q = window.criteo_q || [];
window.criteo_q.push(
        { event: "setAccount", account: {{accountid}} },
        { event: "setEmail", email: "{% if page.account %}{{ page.account.email|lower|md5 }}{% endif %}" },
        { event: "setSiteType", type: (function(){return /iPad/.test(navigator.userAgent)?"t":/Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Silk/.test(navigator.userAgent)?"m":"d"})() }
        {% if template == "pages/index.rain" %}
        ,{ event: "viewHome", ecpplugin: "lightspeed" }
        {% elseif template == "pages/collection.rain" %}
        ,{ event: "viewList", ecpplugin: "lightspeed", item: [{% for prod in collection.products %}'{{prod.id}}',{% endfor %}].slice(0,3) }
        {% elseif  template == "pages/product.rain" %}
        ,{ event: "viewItem", ecpplugin: "lightspeed", item: "{{ product.id }}" }
        {% endif %}
);
</script>
<!-- CRITEO END -->
  • Edit the fixed.rain file and copy the following code provided
<!-- CRITEO START -->
<script type="text/javascript" src="//static.criteo.net/js/ld/ld.js" async="true"></script>
<script type="text/javascript">
console.log("{{template}}");     
window.criteo_q = window.criteo_q || [];
window.criteo_q.push(
        { event: "setAccount", account: {{accountid}} },
        { event: "setEmail", email: "{% if page.account %}{{ page.account.email|lower|md5 }}{% endif %}" },
        { event: "setSiteType", type: (function(){return /iPad/.test(navigator.userAgent)?"t":/Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Silk/.test(navigator.userAgent)?"m":"d"})() });
</script>
        {% if template == "pages/cart.rain" %}                   
            <script>
            var criteo_items = [];
            {% for prod in cart.products %}                                      
              criteo_items.push({
                id: '{{prod.id}}',
                price: parseFloat('{{prod.base.price_incl}}'),
                quantity: parseInt('{{prod.quantity}}')
                });
            {% endfor %}
              window.criteo_q.push(
              { event: "viewBasket", ecpplugin: "lightspeed", item: criteo_items}
              );
            </script>
        {% elseif  template == "pages/thankyou.rain" %}
            <script>
            var criteo_items = [];
            {% for prod in order.products %}                                 
                criteo_items.push({
                    id: '{{prod.product_id}}',
                    price: parseFloat('{{prod.base_price_incl}}'),
                    quantity: parseInt('{{prod.quantity_invoiced}}')
                    });
            {% endfor %}
              window.criteo_q.push(
              { event: "trackTransaction", ecpplugin: "lightspeed", id: '{{order.information.number}}', item: criteo_items}  
              );
            </script>
        {% endif %}
);     
<!-- CRITEO END -->

OneTag 2.0

[[cname]]

Verification

[[accurate]]