RTB House埋点

1、首先打开RTB那边给到的文档(后面简称RTB文档),获取埋点id。
如何获取埋点id?
如:RTB文档里面首页添加的代码为<iframe src="//creativecdn.com/tags?id=pr_4vCFL5KAWFpnxJ1amCXg_home" width="1" height="1" scrolling="no" frameBorder="0" style="display: none;"></iframe>
则埋点id为:4vCFL5KAWFpnxJ1amCXg
2、开始埋点:
  • 埋点文件:layout/theme.liquid
  • 埋点代码:将下面代码的所有埋点id替换为你要埋点站点的埋点id(共7处替换)。
<!--RTB START-->
{% if template contains 'index' %}
    <iframe src="//creativecdn.com/tags?id=pr_4vCFL5KAWFpnxJ1amCXg_home" width="1" height="1" scrolling="no" frameBorder="0" style="display: none;"></iframe>
{% elsif template contains 'collection' %}
    <iframe src="//creativecdn.com/tags?id=pr_4vCFL5KAWFpnxJ1amCXg_category2_{{ collection.id }}" width="1" height="1" scrolling="no" frameBorder="0" style="display: none;"></iframe>
{% elsif template contains 'product' %}
    <iframe src="//creativecdn.com/tags?id=pr_4vCFL5KAWFpnxJ1amCXg_offer_{{ product.id }}" width="1" height="1" scrolling="no" frameBorder="0" style="display: none;"></iframe>
{% elsif template contains 'search' %}
    <iframe src="//creativecdn.com/tags?id=pr_4vCFL5KAWFpnxJ1amCXg_listing_{% for item in search.results limit:5 %}{{ item.id }},{% endfor %}" width="1" height="1" scrolling="no" frameBorder="0" style="display: none;"></iframe>
{% elsif template contains 'cart' %}
{% if cart.item_count > 0 %}
  <iframe src="//creativecdn.com/tags?id=pr_4vCFL5KAWFpnxJ1amCXg_basketstatus_{% for item in cart.items %}{{ item.product.id }},{% endfor %}" width="1" height="1" scrolling="no" frameBorder="0" style="display: none;"></iframe>
{% endif %}
{% else %}
  <iframe src="//creativecdn.com/tags?id=pr_4vCFL5KAWFpnxJ1amCXg" width="1" height="1" scrolling="no" frameBorder="0" style="display: none;"></iframe>
{% endif %}
<script type="text/javascript">
    let current_url = window.location.href;
    if (current_url.indexOf('search-results-page') > -1) {
        window.onload = function(){
            let iframe_tag = generateIframeTag();
            document.body.insertAdjacentHTML("afterbegin", iframe_tag);
        }
    }
    function generateIframeTag(){
        let product_ids = getProductIds();
        let iframe_src = generateIframeSrc(product_ids);
        let iframe = '<iframe src="' + iframe_src + '" width="1" height="1" scrolling="no" frameBorder="0" style="display: none;"></iframe>';
        return iframe;
    }
    function generateIframeSrc(product_ids){
        let iframe_src = "//creativecdn.com/tags?id=pr_4vCFL5KAWFpnxJ1amCXg_listing_";
        for (let id of product_ids){
            iframe_src += id + ",";
        }
        return iframe_src;
    }
    function getProductIds(){
        let products = document.querySelectorAll(".snize-search-results-content .snize-product");
        let product_ids = [];
        for (let product of products){
            let product_dom_id = product.id;
            product_ids.push(product_dom_id.substring(14));
        }
        return product_ids;
    }
</script>
<!--RTB END-->
  • 埋点位置:</body>标签前
  • 埋点截图:avatar
3、站点后台settings->checkout->order processing->additional scripts添加代码
  • 将下面代码的埋点id替换为你要埋站点的埋点id(一处替换)
{% if first_time_accessed %}
<iframe src="//creativecdn.com/tags?id=pr_4vCFL5KAWFpnxJ1amCXg_orderstatus2_{{ total_price | money_without_currency}}_{{ order_number }}_{% for line in order.line_items %}{{ line.product_id }}{% unless forloop.last == true %},{% endunless %}{% endfor %}&amp;cd=default" width="1" height="1" scrolling="no" frameBorder="0" style="display: none;"></iframe>
{% endif %}
  • 将替换好的代码添加到settings->checkout->order processing->additional scripts,如下图所示:

avatar

4、站点后台Online Store->Preferences->Google Analytics->Additional Google Analytics JavaScript添加代码
  • 将下面代码的埋点id替换为你要埋站点的埋点id(一处替换)
var current_url = window.location.href;
if (current_url.indexOf("checkout") > -1) {
    if (current_url.indexOf('shipping_method') > -1) {
        document.body.insertAdjacentHTML("afterbegin", '<iframe src="//creativecdn.com/tags?id=pr_4vCFL5KAWFpnxJ1amCXg" width="1" height="1" scrolling="no" frameBorder="0" style="display: none;"></iframe>');
    } else {
        document.body.insertAdjacentHTML("afterbegin", '<iframe src="//creativecdn.com/tags?id=pr_4vCFL5KAWFpnxJ1amCXg_startorder" width="1" height="1" scrolling="no" frameBorder="0" style="display: none;"></iframe>');
    }
}
  • 将替换好的代码添加到Online Store->Preferences->Google Analytics->Additional Google Analytics,如下图所示:

avatar


文档维护:黎俊阳、王小榆、王星星、林颖

results matching ""

    No results matching ""