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
-
Redirecting one domain to another using utm tags
I have two live websites, which have both been live for over 10 years, so we have plenty of backlinks to both...domain1.com & domain2.com. Domain 1 and all urls is being merged into domain2.com. So 301 redirects will be setup for every page of the site....domain1.com/abc-1234/ to > domain2.com/abc-1234/ In Google analytics for domain2.com we want to be able to see which visits we have received as a result of a redirect from domain1.com. It is possible to see these visits that come in via organic, referrals and social etc, as those will come to us with the referral as domain1.com. However, with direct traffic, i.e. if someone types domain1.com into their search bar, these visits will be assigned as direct and we are not able to tell in GA if those users have typed in domain2.com, or domain1.com to get to our webpage. There are some suggestions in forums of adding utm_source tracking to all redirects (and add canonicals to those urls pointing to the non utm_source version), but my concern is that Google is going to have to go through one extra step to reach the page on the redirected domain. So without the utm source code Google will follow this route
Reporting & Analytics | | Sayers
domain1.com/123/ to domain2.com/123/ With the utm source code Google will follow this route
domain.com/123/ to domain2.com/123/?utm_source... then see's canonical, so moves to domain2.com/123/ So essentially I am giving Google one extra step to follow before it gets to the equivalent page on the new site. Is this an issue, and/or are there any other ways to track this redirection without adding extra parameters to the url?0 -
Google Analytics - Events impacting session data
Hi Mozzers, Has anybody ever experienced event tracking significantly impacting session data? Here's a summary of what I'm finding: When I measure sessions to a particular hostname (a subdomain) in my Google Analytics report, sessions dropped by over 100% when I removed some event tracking on that subdomain (an event was triggered when a user clicked on a particular button). When I reinstate that event tracking, sessions go back up to around where they used to be. Can anybody understand why this might be happening? Thanks!
Reporting & Analytics | | A_Q0 -
How to find goo.gl/ URLs in Google Analytics
Hello! How does one go about finding the impact of goo.gl/ shortened URLs in Google Analytics? (I know I should be using Campaigns, but this was for an old project.) Thanks in advance! Erik
Reporting & Analytics | | SmileMoreSEO0 -
Google Analytics & Omniture Discrepancies
I am seeing a significant difference between my traffic numbers in Google Analytics and Omniture (Omniture has significantly more). I do not expect them to report exactly the same numbers but these are just too far off. Any idea why that is, or which one I should trust more? Thanks!
Reporting & Analytics | | emediaSEO0 -
Google Analytics - Cross Domain Tracking Goals
Hi guys, looking at the best way to organize this - Site 1 - Shoe Store - (Old site with analytic history - UA-12345-1) Site 2 - Clothing Store - (Brand New UA-54321-1) Right now i have 2 separate GA Accounts for the sites. But i would like to track goals from Site 2 to Site 1. For that i need to set up cross domain tracking. So i take it i would need to create another account under Site 1 - (UA-12345-2) and put that new code on Site 2? Or do the UA numbers have to be exact? example both 12345-1? In which case, i would need to set up 2 different profiles with filtering? Main concern is i want to keep separate data for both sites, espically if UA's will be the same. Trying to visualize - UA-12345-1 Profile 1Shoes/Master Profile 2 Shoes Profile 3 Clothes Or UA-12345-1 Shoes UA-12345-2 Clothes Thanks, Mike
Reporting & Analytics | | IsHot0 -
"It appears there's a problem with our connection to your Google Analytics ...
account. Please go to your Settings page to update your connection." I set up a GA account for our website (www.edao.biz) prior to creating the SEO campaign. When I set up the campaign it told me there was a problem. I tried to fix the connection using the Settings page and it created a second account - however, it still cannot connect to it. In the GA account, it shows that I have granted access to pro.seomoz.org. I did not setup a 2-step verification with GA; don't think that's the issue. Should I blow both GA accounts away and try again? I don't think it's working correctly, and I would really like to be able to see the analytics for our site. I did see that in the GA account I had checked [v] Share my Google Analytics data... [v ] with other Google products only. - What should be the proper setting? (BTW I'm a bit lost with the new GA, I still go to the old interface (though ugly, it shows more links and info)) Thank you, Ingrid
Reporting & Analytics | | IngridWood0 -
Using Google Analytics for tracking statistics of the HOMEpage
Hello, Lets say I have a website with the HOMEpage being http://www.page.com. There are various subpages e.g. http://www.page.com/page1, http://www.page.com/page2, http://www.page.com/page3 . Now when I use Google Analytics it gives me all kind of statistics for the subpages shown as /page1 /page2 /page3 ... (relative path). According to this pattern the HOMEpage should be just "/". Unfortunately I can't find "/" in any statistics. Is this normal? Thanks in advance
Reporting & Analytics | | guitarslinger0 -
How Can I Record .zip Traffic in Google Analytics
The company I am with shows traffic coming in to .zip files in Google Analytics. The traffic being recorded stopped a while back, but I know people are still downloading/visiting these .zip ULRs. I'm not sure how they were recording/tracking the .zip URLs (in Analytics) before, but I'd like to track them once again. Does anyone know how to do this? Thanks
Reporting & Analytics | | poolguy0