【问题标题】:Shopify no longer support AnalyticsShopify 不再支持分析
【发布时间】:2017-10-24 15:18:32
【问题描述】:

我的 Shopify Analytics 在 10 月 8 日出现问题,我一直在尝试确定问题的根源。我已经关注了 Digital Darts 的帖子和 Ahmad Kanani 的分步指南,看看我是否遗漏了什么。

Shopify 的技术支持今天通知我,他们目前不支持 Analytics。似乎发生的情况是,当您将新的 gtag.js 代码粘贴到 Shopify 的 Analytics 首选项页面框中时,他们的后端编辑器(我收集到的称为 TinyMCE)会从第一个脚本关闭标记开始剥离剩余的代码,留下一个未封闭的脚本来破坏您的网站。我还没有找到生成遗留代码的方法,因此 Shopify 已经有效地放弃了对 Analytics 的支持,但没有任何公告。

当您在 Online Store >> Preferences >> Google Analytics >> 添加自定义 JavaScript 的框中输入以下代码时

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

  gtag('config', 'UA-96981937-1');
</script>

...它在关闭脚本标记之前被截断,并成为带有未关闭脚本的代码:

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-1">

如果他们说他们不支持 gtag.js,有没有办法更新他们的 .liquid 代码?他们的技术人员建议我从我的 theme.liquid 标题中删除 gtag。

这是来自 Shopify 技术支持的 Keith:

“我们可能会在未来迁移到 gtag.js,具体取决于它的进展情况,但目前不建议将 gtag.js 脚本用于 Shopify(不包括 Shopify Plus 上选择与之合作的商店)它)”

【问题讨论】:

标签: google-analytics shopify


【解决方案1】:

我还没有找到让 gtag.js 与 theme.liquid 一起使用的方法,但您仍然可以在 Preferences 中使用旧的 analytics.js 跟踪:

<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m).   {i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

ga('create', 'GA_TRACKING_ID', 'auto');
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-01-24
    • 2021-10-03
    • 2018-05-17
    • 2012-06-11
    • 2016-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多