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
-
I'm a beginner with Google Analytics, what is a good place to start?
I'm a beginner with Google Analytics, what is a good place to start? Would love to know some simple ways to set up Google Analytics to keep SEO in check. What are some of your suggestions? How would you go about using GA to do this? and what are the alternatives? Thanks!
Reporting & Analytics | | Eric_S
Eric0 -
Track PDF's in Google Analytics
Hi Mozzers, Is it possible to track PDF's via Google Analytics/Google tag manager? I'm not only looking for PDF downloads but for the actual activity when someone opens an interactive PDF document. So would it be possible to have onclick events on buttons in the PDF etc... Many thanks!
Reporting & Analytics | | WeAreDigital_BE
Sander0 -
What are all the 5's in SEO Queries in Analytics?
Every small business client has the same thing. 5 impressions for keywords, row after row, every single month. Why exactly 5 and why month after month the same thing? I see this in every local business I work in - and for very important phrases! It's gotten to the point that I think those are fake and I just look at the impressions that have numbers great than 5. Obviously I have to get their impressions up, but what am I to believe about these?
Reporting & Analytics | | katandmouse0 -
How can I verify if someone is Google Analytics certified?
I am looking to hire an IC to help with analytics. I need to know how I can verify if they are GA certified. They gave me a link to a http://www.starttest.com profile. Is that legit?
Reporting & Analytics | | inhouseseo0 -
Custom Variables to track Vimeo plays on website with Google Analytics?
Hello Everyone, I'm trying to track how many times a Vimeo video is played on my site via GA. Does any of you have any knowledge of how can this be achieved? I've read the documentation and came up with this: After the iframe embed i insert this: Of course the GA is loaded in the header. Does not work, at least i cant see anything in analytics. I have set up the segment as per the attached image. Thanks in advance! Alex E6XnO.png
Reporting & Analytics | | pwpaneuro0 -
Google Analytics Best Practice Set up for Clients
Hi When setting up new Google Analytics accounts for clinets what is the preferred/best practice. At present we have our own company google account and add new clinets this way (to our account) - the disadvantage with this, we can only grant them limited account access otherwise they would be able to view all the accounts we cretaed. Plus we can't link their adwords to the GA account we cretaed them. Is it best practice to set the client up with their own Google Account and then we just link to their account. Advise would be appreciated, thank you.
Reporting & Analytics | | daracreative0 -
How do I set up Google Analytics to track paid visitors from Bing
When looking at Traffic Sources in Google Analytics, Google is broken out into paid and organic visits. I want to do the same with Bing. How do I do it?
Reporting & Analytics | | cpantages0