Bizweb

Hướng dẫn cài đặt giải pháp Criteo trên Bizweb

Overview

Bài viết sau sẽ hưỡng dẫn chi tiết cách cài đặt Criteo trên Bizweb

[[disclaimer-nonplugin]]

Feed

Tạo API key

  • Tạo ứng dụng riêng, vào đường link https://<tên gian hàng>.bizwebvietnam.net/admin/apps/private/create

  • Điền tiêu đề "criteoapi"

  • Cho Quyền đọc ở phần Truy xuất dữ liệu của các tài nguyên
  • Copy và gửi kỹ thuật viên bên Criteo thông tin xác thực 1

Tags

Homepage, Listing, Product and Basket Tag

  • Vào đường link https://<tên gian hàng>.bizwebvietnam.net/admin/themes và chọn Chỉnh sửa HTML/CSS 4

  • Tạo một snippet mới gọi là criteo-tracking

  • Copy nội dung code sau vào snippet
<!-- CRITEO -->
<script type="text/javascript" src="//static.criteo.net/js/ld/ld.js" async="true"></script>
<script type="text/javascript">
    var site_type = (window.innerWidth <= 767) ? 'm' : (window.innerWidth >= 980) ? 'd' : 't';

    window.criteo_q = window.criteo_q || [];
    window.criteo_q.push(
        { event: "setAccount", account: {{accountid}} },
        { event: "setSiteType", type: site_type},
        { event: "setEmail", email: "{{customer.email | remove: " " | strip_newlines | downcase | md5}}"});
</script>
{% case template %}
    {% when 'index' %}
        <script type="text/javascript">
            window.criteo_q.push(
                { event: "viewHome", ecpplugin: "bizweb"}
            );
        </script>
    {% when 'collection' %}
        <script>
            var criteo_items = [];
            {% for item in collection.products limit:3 %}
                criteo_items.push("{{item.id}}");
            {% endfor %}
                window.criteo_q.push(
                    { event: "viewList", ecpplugin: "bizweb", product: criteo_items}
                );
        </script>
    {% when 'product' %}
        <script type="text/javascript">
            window.criteo_q.push(
                { event: "viewItem", ecpplugin: "bizweb", product: "{{ product.id }}" }
            );
        </script>
    {% when 'cart' %}
        <script>
            var criteo_items = [];
            {% for item in cart.items %}
                criteo_items.push({
                    id : "{{item.product.id}}",
                    price : {{item.price | money_without_currency | remove: "," | remove: "₫" }},
                    quantity : {{item.quantity}}
                });
            {% endfor %}
            window.criteo_q.push(
                { event: "viewBasket", ecpplugin: "bizweb", product: criteo_items}
            );
        </script>
{% endcase %}
<!-- END CRITEO -->
  • Mở layout file theme.bwt và chèn đoạn code sau trước khi đóng tag body
<!----- YOU MUST INCLUDE THIS STATMENT WHEN USING A NEW THEME OR CRITEO TAGS WILL BREAK ---------->
    {% include 'criteo-tracking' %}
<!----- YOU MUST INCLUDE THIS STATMENT WHEN USING A NEW THEME OR CRITEO TAGS WILL BREAK ---------->

6

Sales Confirmation Tag

  • Vào phần Cấu hình trang thanh toán qua đường link https://<tên gian hàng>.bizwebvietnam.net/admin/settings/checkout

  • Kéo chuột xuống mục Xử lý đơn hàng, copy đoạn code sau vào Nội dung thông báo thêm 7

<!-- CRITEO START -->
<script type="text/javascript" src="//static.criteo.net/js/ld/ld.js" async="true"></script>
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function(){
    var site_type = (window.innerWidth <= 767) ? 'm' : (window.innerWidth >= 980) ? 'd' : 't';
    var re = /#\d+/gi;
    var $order_summary = $('.order-summary-header');
    var text = '';
    var match = [];
    var transId = (new Date().getTime());
    var email = Bizweb.checkout.email || '';
    var items = [];

    //get Transaction ID
    if($order_summary && $order_summary[0]){
        text = $order_summary[0].innerText;
    }

    match = re.exec(text);
    if(match && match[0]){
        transId = match[0];
    }

    //get cart info
    Bizweb.checkout.line_items.forEach(function(el){
        items.push({
            id: el.product_id,
            quantity: el.quantity,
            price: el.price
        });
    });

    window.criteo_q = window.criteo_q || [];
    window.criteo_q.push(
    { event: "setAccount", account: {{accountid}} },
    { event: "setSiteType", type: site_type},
    { event: "setEmail", email: "{{customer.email | remove: " " | strip_newlines | downcase | md5}}"},
    { event: "trackTransaction", ecpplugin: "bizweb", id: transId, product: items});        
});  
</script>
<!-- CRITEO END -->