GTM脚本禁用shopify站点搜索功能

问题描述 投票:0回答:1

我的 Shopify 网站上有一个错误,如 - 当标题上有 GTM 代码片段时 - 搜索功能不起作用。如果我删除 - 它会起作用。我在想也许这是一个 JS 重叠脚本并将其放置在头部的顶部/中心/底部 - 似乎没有任何作用。有效的方法是 - 仅将脚本删除。

我的 theme.liquid 文件如下

<!doctype html>
<!--[if IE 9]> <html class="ie9 no-js" lang="{{ request.locale.iso_code }}"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!-->
  <html class="no-js" lang="{{ request.locale.iso_code }}">
<!--<![endif]-->

<head>
   <!-- Added by TAPITA SEO SCHEMA-->
  {% if content_for_header contains 'tapita-seo-script-tags' %}
    {% include 'tapita-seo-schema' %}
  {% endif %}
  <!-- /Added by TAPITA SEO SCHEMA --> 

  {% render 'pagefly-head' %}
  <meta name="google-site-verification" content="XXXX-XXXX" />
  <meta name="facebook-domain-verification" content="XXXX" />

  {% comment %}
    //COSMOEDIT
  {% endcomment %}
  {% if request.url contains '/search?q=ddos' or request.url contains '/wpm@' %}
    <meta name="robots" content="noindex">
  {% endif %}

  <meta name="google-site-verification" content="XXXX" />
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0">
  {% if page_description %}
    <meta name="description" content="{{ page_description }}">
  {% endif %}

  {% include 'bitespeed-analytics' %}
  {% include 'framework--social-meta-tags' %}

  {% if template contains 'collection' and current_tags %} 
    <link rel="canonical" href="{{ shop.url }}{{ collection.url }}" /> 
  {% else %} 
    <link rel="canonical" href="{{ canonical_url }}" /> 
  {% endif %}

  {% if request.path == '/collections/vendors' and collection.all_products_count == 0 %}
    <meta name="robots" content="noindex">
  {% endif %}
  <link rel="preconnect" href="https://cdn.shopify.com">

  {% if settings.favicon != nil %}
    <link rel="shortcut icon" href="{{ settings.favicon | img_url: '32x32' }}" type="image/png">
  {% endif %}

  <title>{% if template contains "index" %}{{ page_title }}{% else %}{{ page_title }}{% if current_tags %} {{ 'general.meta.tagged_html' | t: tags: meta_tags }}{% endif %}{% if current_page != 1 %} {{ 'general.meta.page' | t: page_number: current_page }}{% endif %}{% endif %}</title>

  {% render 'treedify' %}{%- if tinyscript -%}{{ content_for_header }}{%- else -%}{% render 'tiny-script-control' %}{%- endif -%}
  {%- render 'bold-common' -%}
  {% include 'framework--css-variables' %}
  {% include 'partial--css-variables' %}

  {{ "theme.css" | asset_url | stylesheet_tag }}
  {{ 'theme--customizations.css' | asset_url | stylesheet_tag }}

  {% include 'partial--js-variables' %}

  {{ 'lazysizes.min.js' | asset_url | script_tag }}

  {% if template contains 'customers' %}
    {{ 'shopify_common.js' | shopify_asset_url | script_tag }}
    {{ 'customer_area.js'  | shopify_asset_url | script_tag }}
  {% endif %}

  {{ "theme.js" | asset_url | script_tag }}
  
  {% render 'pagefly-header' %}
  <!-- Zapiet | Store Pickup + Delivery -->
  {% include 'storepickup' %}
  <!-- Zapiet | Store Pickup + Delivery -->
  {% include 'scapp-customerinfo' %} 
  {% include 'sca.storepickup' %}
  {{ 'ndnapps-contactform-styles.css' | asset_url | stylesheet_tag }}
  {{ 'ndnapps-formbuilder-styles.css' | asset_url | stylesheet_tag }}
  <script src="//staticxx.s3.amazonaws.com/aio_stats_lib_v1.min.js?v=1.0"></script>
  {% include 'bss-product-labels-configs' %}
  
  {% include 'dataLayer-allPages' %}
  <script>
      window.dataLayer = window.dataLayer || [];
  </script>
  
  <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
  new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
  j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
  'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
  })(window,document,'script','dataLayer','GTM-XXXXX');</script>
</head>
              
  {% include 'partial--body-classes' %}
  <body
    class="{{ body_classes }}"
    data-theme-id="833"
    data-theme-name="Local"
    data-theme-version="3.3.3"
    {% if template contains 'customers' %}data-account-template="true"{% endif %}
  >
 
{% if content_for_header contains 'tapita-seo-script-tags' %}
{%- capture tapita-seo-snippets -%}
{% include 'tapita-page-speed-status' %}
{%- if tapitaPageSpeedStatus -%}
{% include 'tapita-splash-img' %}
{%- endif -%}
{%- endcapture -%}
{%- unless tapita-seo-snippets contains 'Liquid error' -%}
{{ tapita-seo-snippets }}
{%- endunless -%}
{% endif %}
 

    <!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXX"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
    <div
      class="off-canvas--viewport"
      data-js-class="OffCanvas"
      data-off-canvas--state="closed"
    >
      <div class="off-canvas--overlay"></div>
      <div class="off-canvas--close">
        {% include 'framework--icons', icon: 'cross' %}
      </div>

      <div class="off-canvas--left-sidebar">
        {% include 'layout--mobile-nav' %}
      </div>

      <div class="off-canvas--main-content">
        <div class="fullscreen-container">
          {% if template contains 'index' %}
            {% section 'index--banner' %}
          {% endif %}
          {% unless template == 'password' %}
            {% section 'announcement' %}
            {% section 'header' %}
          {% endunless %}
        </div>

        <main class="layout--main-content">
          {{ content_for_layout }}
    <noscript class="endOfLayoutContentX" type="text/mark"></noscript>{% render 'treedify_script' %}
        </main>

        {% section 'framework--footer' %}

        {% if settings.popup--enabled %}
          {% include 'partial--popup' %}
        {% endif %}

        {% include 'partial--feedback-bar' %}

      </div>

      <div class="off-canvas--right-sidebar">
        {% if settings.cart--type == 'drawer' or settings.product--show-quick-add-buttons %}
          {% include 'framework--cart', view: 'mobile' %}
        {% endif %}
      </div>
    </div>

    {% include 'framework--search', view: 'modal' %}

    {% include 'framework--modal' %}

  

{% include 'whatsapp-share' %}

{% include 'mw_DD_objects' %}{%- render 'bold-currency-converter' -%}
{% include 'mw_fees_objects' %}
  

{{ 'ndnapps-contactform-script.js' | asset_url | script_tag }}
{{ 'ndnapps-formbuilder-script.js' | asset_url | script_tag }}
 {% include 'smile-initializer' %}

{% if content_for_header contains 'product_label' %}{% include 'bss-product-label-js' %}{% include 'bss-label-style-css' %}{% endif %}{{ '//cdn.shopify.com/s/files/1/0194/1736/6592/t/1/assets/booster-page-speed-optimizer.js?23' | script_tag }}

</body>
   
</html>

标题上的

{% render 'pagefly-head' %}
位于下方

{% if page and page.metafields.pagefly.html_meta %}
  {{page.metafields.pagefly.html_meta}}
{% endif %}

标题上的

{% render 'pagefly-header' %}
位于下方

<script>window.__pagefly_analytics_settings__={"acceptTracking":true};</script>

我在这里没看到什么?

javascript shopify google-tag-manager shopify-app
1个回答
0
投票

您调试得不够。

首先检查您的实施是否有效。你看到 GTM 加载了吗? 现在看看问题是否在于您加载它的方式与 GTM 本身的内容。阻止对 GTM 的网络请求,看看是否可以解决您的搜索问题。如果确实如此,则问题出在 GTM 上。进入它并查看它部署了哪些 CHTML 标记。最有可能的是 CHTML 格式。

同时删除 noscript 部分。这没有什么好处。 GTM 应该停止推荐这种废话,但他们喜欢暗示他们的 TMS 无需 JS 即可工作。

检查控制台是否有 JS 错误。

© www.soinside.com 2019 - 2024. All rights reserved.