You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为何Google Analytics追踪表单提交数据与购物车链接?如何停止?

Hey there! Let’s break down your questions about Google Analytics (GA) tracking and how to fix the unwanted tracking for form submissions and that specific shopping cart link.

Form Submissions

GA typically tracks form submissions in two main ways:

  • Pageview triggers: If your form submission reloads the page or redirects to a confirmation page, GA’s default pageview tracking will automatically log this new page load as a session hit.
  • Custom event tracking: If someone added explicit event tracking code (like gtag('event', 'form_submit', ...) or ga('send', 'event', ...)) to your form, GA will actively send an event hit every time the form is submitted.

That link (/de/shop/pizza.html?tx_pizza_basket[action]=addToCart&tx_pizza_basket[controller]=Basket&cHash=...) is a GET request with unique query parameters. GA treats URLs with different query parameters as distinct pages by default, so clicking this link triggers a new pageview hit because it loads a unique URL (even if the core content is just the shopping cart).

How to Stop Tracking These Actions

Let’s go through solutions for each scenario:

Stopping Form Submission Tracking

Choose the method that fits how your form is set up:

  • Prevent page reloads (AJAX submission): If you can modify the form to submit data via AJAX instead of reloading/redirecting, GA won’t trigger a new pageview. You’ll need to update your form’s JavaScript to handle submission without navigating away.
  • Remove custom event tracking: Check your GA code for any lines that explicitly send an event on form submit (like gtag('event', 'form_submit', { ... })). Delete or comment out those lines to stop event tracking for submissions.
  • Use GA View Filters: In your GA Admin panel (under View > Filters), create an Exclude filter to block pageviews from your form’s confirmation URL. For example, set the filter field to Request URI and the filter pattern to match your form’s submission path (e.g., /form-confirmation).

Again, pick the approach that works for your site’s setup:

  • Prevent link navigation: If the link is supposed to open a cart popup (not load a new page), modify the link to use JavaScript instead of a full page load. Add an onclick handler to stop the default navigation:
    <a href="/de/shop/pizza.html?tx_pizza_basket[action]=addToCart&..." onclick="event.preventDefault(); openShoppingCart();">View Cart</a>
    
    Then implement the openShoppingCart() function to load the cart content dynamically without reloading the page. This way, GA won’t log a new pageview.
  • Rewrite the page path in GA: If you have to keep the page reload, override the page path GA sends so all cart-related URLs are grouped under a single entry. Add this code before your GA config or send pageview call:
    const currentUrl = window.location.href;
    if (currentUrl.includes('tx_pizza_basket[action]=addToCart')) {
      // Replace with your clean cart page path
      gtag('set', 'page_path', '/de/shop/cart');
    }
    gtag('config', 'YOUR_GA_TRACKING_ID');
    
    For older analytics.js code:
    ga('create', 'UA-XXXXXXXXX-X', 'auto');
    const currentPath = window.location.pathname + window.location.search;
    if (currentPath.includes('tx_pizza_basket[action]=addToCart')) {
      ga('set', 'page', '/de/shop/cart');
    }
    ga('send', 'pageview');
    
  • Use GA View Filters: Create an Exclude filter in GA Admin to block any URL containing tx_pizza_basket[action]=addToCart. Set the filter field to Request URI and the pattern to tx_pizza_basket\[action\]=addToCart (escape brackets for regex).

内容的提问来源于stack exchange,提问作者user838531

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 04:05:46