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
-
Why do WMT's Search Analytics & GA's Real Time Keywords Differ?
I took a screen shot of the keywords from Google Analytics Real Time Keywords for Google / Organic. Then I waited a week and filtered Google Webmaster Tools' Search Analytics for queries with those keywords. None of them showed up. Why not? What I missing? Why do some keywords show up in Google Analytics RT for Google / Organic while most others are in Not Provided? I see WMT's Search Analytics says that it doesn't always show queries that "are made a very small number of times or those that contain personal or sensitive information." But most of my queries are like that. Anybody know any patterns / criteria that leads WMT to show some but not others? Thanks
Reporting & Analytics | | GilReich0 -
How does Google Maps/G+ traffic show up in Analytics?
Hi Moz Community, I've been trying to figure out how traffic from Google Maps (and G+) shows up in Google Analytics and am struggling to find a good answer online. If someone finds a business through Google Maps and then clicks on the website in the Maps listing, does that show up as a referral from Google Maps? Our site shows virtually zero traffic from Google Maps even though we have a number of listing. Two related questions: if someone clicks through to a G+ page from a Maps result and then visits our website from the G+ page, does that show up in Analytics as a referral from G+? Is traffic from Google Maps or G+ ALSO counted as organic traffic? (Would it be possible to accidentally double-count a visit as both organic and a referral from Maps/G+? Thanks everybody!
Reporting & Analytics | | JohnGroves0 -
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 -
I want to upgrade to Universal Analytics but already using GTM and I have few queries...
Hello Experts, I want to migrate from classical to universal analytics and i am already using GTM for my ecommerce site. I have small 6 queries :- After login to google analytics from admin section i have to transfer property to universal analytics ? right? I have to wait either 24 hours or 48 hours before retagging or doing any changes in UA. So how can i know my property transferred sucessfully? After property transferred to universal analytics, i have to configure the session timeout and campaign timeout periods via the Google Analytics Admin page. ( By default,
Reporting & Analytics | | jackinmathis1
sessions end after 30 minutes and campaigns end after 6 months ) is it okay if i don't change this settings? As of now in my analytic i have configured google adwords, google webmaster and google merchant. In analytic i have also set custom alerts, goals, funnels, enchance link attribution, eCommerce etc but google analytics code i have already added in google tag manager, so i have to some manual changes for all such things? or all the things i.e goals, funnel, alerts etc will be transferred automatically at time of transferring the property? In Google tag manager i have already configured following things :- Tags :- Name - Google adwords Conversion Tracking b) Type - Adwords Conversion Tracking c) Rules - order sucessful page Name - Google Analytic Page view Tracking b) Type - Classic Google Analytics c) Rules - All pages Name - Google Analytic Conversion Tracking b) Type - Classic Google Analytics c) Rules - order sucessful page Name - Twitter Conversion Tracking b) Type - Custom HTML tag c) Rules - order sucessful page So at time of transferring property all this will be transferred automatically? Also at thank you page of my website I have scripts for goal setting, Affiliator, so there is no relation of this with migration right? Kind co-operation in the matter of highly be appreciated. So please help me! Regards,
Jackin!0 -
Tag Manager & Universal Analytics Code - Do you need both?
Hi Mozzers I've created a container for a domain in Google Tag Manager. Within that container I've created a tag for universal analytics with track type "Page view" and the firing rule "all pages". Can I then replace the Universal Analytics code with the tag manager code? Would it still track all the normal data in Google Analytics? There are no events setup up yet so that's not a concern but there are goals setup tracking which are triggered by a page view. Would they be affected? Thanks Anthony
Reporting & Analytics | | Tone_Agency1 -
Re-classifying a Traffic Source in Google Analytics
Hey All, I think it's inside of the Admin section of Google Analytics, right now I have a traffic source from the domain of indeed.ca that is being classified as Organic traffic when it should be classified as referring traffic, how can I tell Google Analytics that all traffic from this source should be classified as referral traffic and not organic traffic? Furthermore, after I make this change, will Google Analytics re-classify my past data so I can do a proper analysis? I can't remember how to do this and any help would be appreciated! Thanks!
Reporting & Analytics | | EvansHunt1 -
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 -
Google Analytics Custom Filter
Hello, Quick question, when I create a custom filter on a profile that already has data collected will that filter apply to already collected data or will the filter only apply from the day it was created? Am doing a custom exclude IP filter. Much thanks,
Reporting & Analytics | | Unity
Davinia0