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
-
Google Analytics Tutorials
Hi, I'm trying to beef up my knowledge of google analytics. Can you pelase tell me where I can find some good Google analytics tutorials?
Reporting & Analytics | | corn20150 -
AHHH... Google Analytics just changed!
There's now an acquisitions tab.. but I can't figure out how to sort referral traffic by referral path.
Reporting & Analytics | | S.S.N0 -
Google Analytics question
Hi, I recently relaunched my site on a wordpress CMS. The relaunch has gone well except for a category of traffic within Google Analytics which is referral traffic from google.co.uk (its a UK site) which has dropped off hugely. The non-paid search traffic from google.co.uk is the same or better than it was. Can anyone tell me what the difference is between referral traffic from google.co.uk and non-paid search traffic from google.co.uk. Thanks for your help. Ben
Reporting & Analytics | | benacuity0 -
Google Analytics data - Canonical problems?
Hi everyone, We're trying to determine why Google Analytics is showing multiple versions of the same page as having "landing page traffic". For instance, these 2 pages are both shown as landing pages in GA: www.oursite.com/product_page
Reporting & Analytics | | darkgreenguy
www.oursite.com/product_page/ This occurs many times in Google analytics. Also, there are instances such as these: www.oursite.com/index.php/custom_product_url www.oursite.com/custom_product_url I can't find anything in Google Webmaster tools that would indicate a problem. However, this GA data is making me think there are duplicate content issues on the site... Thanks in advance for any help...0 -
Switching Google Analytics from Urchin to GA
I want to finally make the switch from Urchin to GA in Analytics, but the Google support page is no longer working (I realize I'm late to this so they likely took it down/moved it to where I can't find it). I've been searching on Google but can't find a straightforward guide to changing that won't disrupt my data. Anyone have a link to a working guide, or can you provide some guidance?
Reporting & Analytics | | Axios_Systems0 -
What's the difference between landing pages and entrance pages on Google Analytics?
I'm confused about the difference between entrance pages and landing pages on Google Analytics. If I compare our search traffic to entrance pages with search traffic to landing pages it seems very similar -- but not identical. But this is probably because all of our GA analytics is sampled (we're a huge site). Can anyone help?
Reporting & Analytics | | CecilyP0 -
Transfer Google Analytics data from one user to another?
Long story short, two weeks of analytics data are stored on a different profile from the rest of the year's data. Is there a way to export all data from a date range, and then import it to another account? Thanks for your help.
Reporting & Analytics | | AmericanOutlets0 -
Google Analytics bug?
Hi, I'm getting hits to this page, it's screwing up my Google Analytics stats. I know it's related with Google Website Optimizer, cuz it correlates with the tests I ran at the same dates. I'm just wondering if you've seen this before and what I should do to clean my stats? And is this affecting my SEO? Because it's still registering hits to these pages but I already stopped the tests a while go. Should I disallow this in my robots.txt file? Thanks! ga_bug3.jpg
Reporting & Analytics | | rhenster990