0

我在我的 shopify 结帐页面中使用下面的转换脚本。我有两个问题:'

  1. Shopify.checkout.total_price_set.presentment_money.amount在 chrome 开发人员工具中查看时,该对象Shopify.checkout.total_price_set.presentment_money.currency_code显示在 console.log 中,但未显示在页面源中。它按原样显示。谷歌封面正在正确记录日期,但我需要知道为什么这个对象没有在页面源中显示值,这是我使用的正确对象吗?我应该使用其他 shopify 结帐对象吗? 显示 gtag 对象的页面源

这是console.log 控制台日志

  1. 增强型电子商务数据是必需的,但谷歌转换在诊断中报告格式无效。 增强型电子商务

谁能帮我理解上述2?

<!-- Global site tag (gtag.js) -  -->
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-xxxxxxx"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

gtag('config', 'AW-xxxxxxxx', { 'allow_enhanced_conversions': true });
</script>


<script>
var enhanced_conversion_data = {
  {% unless checkout.email == blank %}"email": "{{ checkout.email }}",{% endunless %}
  {% unless billing_address.phone == blank %}"phone_number": "{{ billing_address.phone }}",{% endunless %}
  {% unless billing_address.first_name == blank %}"first_name": "{{ billing_address.first_name }}",{% endunless %}
  {% unless billing_address.last_name == blank %}"last_name": "{{ billing_address.last_name }}",{% endunless %}
  "home_address": {
    {% unless billing_address.street == blank %}"street": "{{ billing_address.street }}",{% endunless %}
    {% unless billing_address.city == blank %}"city": "{{ billing_address.city }}",{% endunless %}
    {% unless billing_address.province_code == blank %}"region": "{{ billing_address.province_code }}",{% endunless %}
    {% unless billing_address.zip == blank %}"postal_code": "{{ billing_address.zip }}",{% endunless %}
    {% unless billing_address.country_code == blank %}"country": "{{ billing_address.country_code }}"{% endunless %}
  }
};
</script>
<script type="text/javascript">
  gtag('event', 'conversion', {
    'send_to': 'AW-xxxxxxxx/xxxxxxxxxxxxxxx',
    'transaction_id': '{{ order.order_name }}',
    'value': Shopify.checkout.total_price_set.presentment_money.amount,
    'currency': Shopify.checkout.total_price_set.presentment_money.currency_code,
    'discount': discount(),
    'aw_merchant_id': 'xxxxxxxx',
    'aw_feed_country': 'IN',
    'aw_feed_language': 'EN',
    'items': items()
  });
  function discount(){
    if (Shopify.checkout.discount == null) {
      return 0;
    } else {
      return Shopify.checkout.discount.amount;
    }
  }
  function items(){
    var jsonarray = [];
    for (var line_item_count = 0; line_item_count < Shopify.checkout.line_items.length; line_item_count++){
      var jsonobj = {
        id: Shopify.checkout.line_items[line_item_count].sku,
        quantity: Shopify.checkout.line_items[line_item_count].quantity,
        price: Shopify.checkout.line_items[line_item_count].line_price
      };
      jsonarray.push(jsonobj)
    }
    return jsonarray;
  }

  console.log({
    'value': Shopify.checkout.total_price_set.presentment_money.amount,
    'currency': Shopify.checkout.total_price_set.presentment_money.currency_code,
    'discount': discount(),
    'items': items()
  });
</script>

此外,转换应该只报告给谷歌在广告管理器中提供的转换标签,或者也应该发送到分析帐户(您可以在此链接上看到此代码https://www.digitaldarts.com.au/google-ads-conversion-tracking-shopify

{% assign UA-ID = "UA-PROPERTY_ID" -%}{%- comment -%}Google Analytics tracking ID.{%- endcomment -%}
{%- assign AW-ID = "AW-GOOGLE_CONVERSION_ID" -%}{%- comment -%}Google Ads conversion ID.{%- endcomment -%}
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ UA-ID }}"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', '{{ UA-ID }}');
  gtag('config', '{{ AW-ID }}', { 'allow_enhanced_conversions': true });
</script>

在上面的代码中,它正在向谷歌分析帐户发送数据,并在 gtag 中添加了转换作为参数

4

0 回答 0