惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
T
The Blog of Author Tim Ferriss
G
Google Developers Blog
博客园_首页
博客园 - 【当耐特】
量子位
S
SegmentFault 最新的问题
B
Blog RSS Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
V
Visual Studio Blog
T
Tailwind CSS Blog
阮一峰的网络日志
阮一峰的网络日志
V
V2EX
Y
Y Combinator Blog
博客园 - 聂微东
The Cloudflare Blog
小众软件
小众软件
J
Java Code Geeks
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
月光博客
月光博客
H
Help Net Security
Jina AI
Jina AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
宝玉的分享
宝玉的分享

Blog of Simple Analytics

The EU wants to kill cookie banners Google is tracking you (even when you use DuckDuckGo) German court rules Meta’s tracking tech violates GDPR Closing the data gap - Simple Analytics x Usercentrics The EU-US data deal may be dead in the water You are missing 20% of your website data with GA4 How a reverse trial will push Simple Analytics to the next level Google will start tracking all your devices (WTF?) Big Tech Fails EU’s Digital Services Act: Only Wikipedia Passes the Test Meta fined $102 million by the Irish Data Protection Commission Europeans spend 575 Million hours per year clicking cookie banners The most interesting GDPR fines GDPR and fines: all there is to know Google loses key antitrust case Web Analytics for Crypto Companies Web analytics for publishers Google pulls Uno Reverse card: Rolls back decision to kill third-party cookies Privacy Monthly July 2024 Privacy Perspectives June 2024 Privacy Monthly June APRA fumbles targeted advertising Privacy Monthly May Meta loses key privacy battle Google delays cookie phase-out once again Privacy Monthly April 2024 Web Analytics and Consent Cookies 101 Privacy Monthly March 2024 German authority cracks down on cookie banners Google Tag Manager vs Google Analytics
How to track form submissions using Google Tag Manager?
Iron Brands · 2023-04-24 · via Blog of Simple Analytics

This documentation page will guide you through tracking form submissions on your website using Simple Analytics and Google Tag Manager.

The process involves creating custom events within Google Tag Manager, which then sends the data to Simple Analytics. This is particularly useful when you want to monitor how many users submit forms on your site and gather insights into user behavior.

First, we have created a test website for demonstration purposes, which includes a simple form containing an email address field and a submit button.

events-gtm-testwebsite.png

You want to track how often users click the submit button and see the corresponding data in Simple Analytics.

To achieve this in Google Tag Manager, follow the steps below:

  1. Open Google Tag Manager and make sure you're in the appropriate workspace.
  2. Navigate to the "Tags" section. If you haven't already installed the Simple Analytics tag, do so now.
  3. Create a new tag and select "Custom HTML."
  4. Enter the following code snippet in HTML.
<script>
if (window.sa_event) {
  sa_event("form_submit");
}
<script>

This code checks if Simple Analytics is loaded and sends a "form_submit" event to Simple Analytics when the form is submitted.

Next, scroll down and open de “Advanced Settings” section.

  1. In the "Advanced Settings" section, configure Google Tag Manager to fire this tag after the Simple Analytics tag. Like this:

events-gtm-fire.png

  1. Name the tag "Form Submissions" and select "Simple Analytics" from your existing tags.
  2. Close "Advanced Settings" and set up a trigger for the form submit event.
  3. Click the "+" button to create a new trigger named "Form Submit Trigger".

event-gtm-tag.png

  1. Find and select "Form Submission" from the list, then save the trigger.
  2. Link the trigger to the custom HTML code you created earlier.
  3. Save and submit the changes in Google Tag Manager.

After refreshing your test website and submitting the form, you can check the Simple Analytics Events Explorer to see if the "form_submit" event has been recorded.

events-gtm-dashbaord.png

You can also view the page where the event occurred, such as the home page, and any additional information you've added.

To further enhance your form tracking capabilities, you can utilize data points from the data layer within Google Tag Manager. Follow these steps to configure built-in form variables and use them in your Google Analytics tag:

  1. In Google Tag Manager, go to "Variables" and configure the built-in variables by scrolling down and selecting the appropriate form variables.

events-gtm-form-classes-etc.png

  1. With these variables available, navigate to "Tags" and open the "Form Submissions" tag.
  2. To use the form classes variable as metadata, add a new curly bracket object within the code snippet. Type "form classes" followed by double quotes, and the form classes variable should appear as an option.

events-gtm-form-calsses.png

  1. By selecting "form classes," you instruct the script to send the form classes data from your website as metadata to Simple Analytics.
  2. You can use other variables, such as "ID" or "target" depending on your website's requirements. In this example, we'll focus on form classes.
  3. To verify the form classes data, inspect the form element on your test website. The form should display the class attribute with the specified class name.
  4. Return to Google Tag Manager, save the changes, and publish your updates.
  5. Refresh your example website, submit the form, and check Simple Analytics for the recorded "form_submit" event and the associated form class metadata.

events-gtm-form-classes-dashboard.png

By incorporating form variables and metadata into your tracking strategy, you can effectively monitor form performance on your website and optimize the user experience.