Is it possible to use Google Tag Manager to pass a user’s text input into a form field to Google analytics?
-
Hey Everyone,
I finally figured out how to use auto event tracking with Google Tag Manager, but didn't get the data I wanted. I want to see what users are typing into the search field on my site (the URL structure of my site isn't set up properly to use GA's built-in site search tracking). So, I set up the form submit event tracking in Google Tag Manager and used the following as my event tracking parameters:
Category: Search
Action: Search Value
When I test and look in Google Analytics I just see: "search" and "search value." I wanted to see the text that I searched on my site. Not just the Action and Category of the event....
Is what I'm trying to do even possible? Do I need to set up a different event tracking parameter?
Thanks everyone!
-
Hey Mike,
Thanks so much for the reply. I apologize for taking so long to respond! I have my Moz emails separated into a different email folder that I rarely check. We ended up abandoning GTM and coming up with a developer supplied solution, but I'd still love to try this out. We'd love to be able to do all of the event tracking without involving developers! I will try this out within the next few weeks on a new site and definitely respond back.
Thanks Mike.
-
Hi Melanie,
Definitely possible using GTM's Data Layer object, but it'll take a little work to make it happen.
Two resources I'd recommend a deep dive into to understand this logic:
- Google's Tag Manager Developer's Guide explains how to work with the data layer - I'd consider this mandatory reading as there are a few basic setup steps for utilizing the data layer object
- This great tutorial video from Eric Fettman at KISSmetrics (which I'm borrowing a bit from below) is a great, clear walkthrough - the whole video is solid, but if you're looking to jump right to the bit that applies to this case, go to 9:20
The following is my basic stab at what you'll need to do, but you should by no means consider this foolproof - testing and adjustment will be required.
You'll basically want to...
-
Use the dataLayer object in your form HTML to push an event with the search field value into the data layer upon the form's submission
For example: < form name="myform" onsubmit="dataLayer.push({event','search','eventLabel':[searchvalue]});" /> where search is the name of your new custom event, which you'll listen for with a new GTM event tag & rule combo (following steps), and you must replace [searchvalue] with the value of your search form field via JS or jQuery - that last bit is a little tricky and will probably require a separate function to parse the DOM and grab the value from the search field, but I'd look at the same basic functionality that JavaScript Form Validation uses as a starting point. Maybe someone with stronger JS skills than mine can help you sort that piece.
-
Create a new event tag in GTM with custom Category and Action static values (maybe "search" and "search performed"), adding a Macro with the type "Data Layer Variable," with a Data Layer Variable Name of eventLabel (which is what we used in the HTML code above - crucial that these match) and Data Layer Version set to 1
-
Create a rule for this new tag to fire when the Condition {{event}} equals search (or whatever you've specified as the event name in your form HTML above
It can be a little confusing wrapping your head around this combination of pushing a custom event along with a dynamic event label into the data layer and using that to trigger a rule+event combo to grab that data and push it with your custom event values into GA, but when you think through the logic a few times it becomes clearer.
I'd love to hear whether this did the trick or at least led you down the right track if you don't mind circling back in this thread.
Best,
Mike
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
Referral issue in Google analytics
We have an eCommerce website that counts paypal as a referral source in Analytics. The site takes people to Paypal to make a payment and then back to the website to a Thank You page once that payment has been made. Due to this, Analytics sees this as a conversion that has come from Paypal, and also records it as a referral source, when we know this is not really the case. This also distorts the data in analytics and prohibits us from clearly seeing which channels sales have come from. Is there anyway in Analytics to include Paypal as a part of the website so that it does not record Paypal as a separate referral website?
Reporting & Analytics | | Gavo0 -
Linking My Google analytics with visual.ly
Hello, I have a quick question: Is it secure and safe to link my Google Analytics account with Visual.ly here's the link: https://create.visual.ly/graphic/google-analytics I want to create easy-to-understand report from Google Analytics and if you have any experience with this service can you share it with me please. Thanks.
Reporting & Analytics | | JonsonSwartz0 -
Is it possible to attached separate analytic codes for each campaign?
I am having difficulty in using different GA codes for each individual campaign- this must be possible. Can someone please advice. Thanks
Reporting & Analytics | | ChrisDingley0 -
How do I manually add transactions to Google Analytics
We are seeing Google Analytic's drop transaction on our site so therefore all the figures are skewed. Is there a way I can manually add transactions to GA to cover the missing one?
Reporting & Analytics | | Towelsrus0 -
Google Maps not passing referral data
Google Maps is not passing referral data (URLs, not KWs). Google+ Local is referring, but nothing from maps. Maps referrals appear to be coming across as direct. Any ideas? We haven't found anything online, one of the guys at the office documented what we did find, using Chrome's debugger - http://manofactionmetrics.com/2012/11/02/google-maps-not-passing-any-referral-data/
Reporting & Analytics | | Danieljacobree0 -
Cross domain tracking setup in Google Analytics
I really need help on this, I can't figure it out. I need to track a few subdomains and and couple of seperate domains in one profile in Google Analytics. So I have: www.maindomain.co.uk sub1.maindomain.co.uk sub2.maindomain.co.uk www.anotherdomain.co.uk So the code I have placed on all of these domains is as following: I have then set up seperate profiles which filter out the data by domain. E.g. for sub1.maindomain.co.uk, I have user the fitler: Custom filter > Include > Filter Field = Hostname > Filter Pattern = sub1.maindomain.co.uk For the www.anotherdomain.co.uk, I have used the same filter. Now this all seems to be tracking visits and unique visitors okay, but I always have a very low pageview count, less than visits and sometimes zero. Could anyone shed any light on what I am doing wrong? Thanks in advance mozzers.
Reporting & Analytics | | MirandaP0 -
Google Analytics Title tag vs landing page visitors numbers
Hi folks, Just wondering if anyone has any ideas as to why im getting different results in Google analytics. I'm using the Content Efficiency Analysis Report from http://www.kaushik.net which is absolutely awesome. When I search via my title tag I get 920 Unique Visitors over the month but when I search via the landing page URL with the same title tag I get 28. Any ideas to why their should be such a difference. I've also noticed that on that page i'm also getting a Rel Cononical TRUE using a site crawl. Any ideas are much appreciated
Reporting & Analytics | | acs1110 -
Use SEOmoz API in Google Docs Spreadsheet
Hi, Has anyone made functions to get link metrics from SEOmoz API in Google docs spreadsheet? Page Authority Domain Authority Linking Root Domains Total Links _Thanks to Tom Critchlow I got the social metrics, now I just need the ones from SEOmoz api. _ Any help would be sweet.
Reporting & Analytics | | EdgySEO0