Want to track AJAX form submits. Is this correct?
-
Hi!
I would like to track everytime a visitor clicks a AJAX contact form's submit button. I created an event in Google Analytics and plan to add some javascript to the submit button code.
This is the current submit button code:
This is how it'll look after I add the category, action, etc.:
Is this correct or am I missing something? Please let me know if you need further detail.
Thanks a lot!
-
That looks good to me. If you are unaware, once you get that event tracking properly, you can also setup conversion goals in GA which are triggered by custom events.
-
Hi Benjamin,
Thanks for taking the time to reply.
I posted my question 4 days ago and frankly had lost all hope for a reply so I asked in another forum and got the same recommendation. So I added the GA category, action, etc to the javascript validation section as you can see belowsuccess: function(data){ if(data == 'true'){ jQuery('input, select, textarea', form).val('').css({'background-position': '5px 9px'}); jQuery(message).html('Message sent.'); _gaq.push(['_trackEvent', 'Contact', 'Inquiry', 'Inquiry Form', 0, false]); }}
I'm waiting for the developer to implement this and see if it works.Well, thanks again and if you have further comments they're are more than welcome
-
Hi Alfredo,
Your syntax there all looks correct.
I'd recommend though, if it's possible, to instead trigger the event after the form submission has gone through. In your code above, the event will trigger whether or not the submission goes through, so if the user gets stopped by validation or something, it'll still count as a submission.
In any case, what you have above is correct.
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
-
Change Phone Number Based on Traffic Source + Ping URL for Call Tracking Number
Hi Everyone, Is there a tool that can change the phone number on a web page based on the visitor source (i.e., direct, organic, paid, etc.)? I'd like to implement a solution like this with different call tracking numbers based on the visitor source. We use the Google suite for our analytics (GA, GTM, Google Data Studio, Google Optimize is also an option as well). - Also, is there a good call tracking service that will ping a URL each time the phone number is called so that we can track these calls as events in GA? The majority of our visitors use a desktop PC and dial in the number on the screen rather than clicking (tapping) on it from a mobile device. Thanks, Andy
Reporting & Analytics | | AndyRCWRCM0 -
Tracking Mailto Links Through Event Tracking
Hi I am trying to get event tracking working on some mailto links on a website using Universal Analytics. I've read various resources as nothing seems to mention mailto links. Does it not work on tracking outbound clicks on emails? Thanks in advance.
Reporting & Analytics | | Karen_Dauncey0 -
E Commerce and cross domain tracking on universal analytics?
Hi Mozzers, I am running into an issue where my client's website ( can refer to domain.com) uses a third party checkout site called rezovation that we can refer to checkout.rezovation.com: I went through this doc here https://developers.google.com/analytics/devguides/collection/analyticsjs/cross-domain and https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce (for universal analytics) and I still find it confusing so here are my questions: According to my understanding I need a customized GATC to link both domains checkout.rezovation.com and domain.com? If yes(above), do we setup one customized GATC for cross domain tracking on all pages from checkout.rezovation.com and domain.com? if it is the case can someone provide detail steps on how to set it up ( I am not a coder so the easier the guideline, the better) Once cross domain tracking is set up, e commerce tracking code should be only on thank you page should be looking like the image below? Should i add manually all the extra code for the ecommerce tracking code or I can get it done via a third party website? Thank you guys! oPgn8P4.png
Reporting & Analytics | | Ideas-Money-Art0 -
How to track link building? What metrics?
I'm an SEO newbie (my main roles are front-end designer and content manager).
Reporting & Analytics | | RSGregC
I've been managing our company's effort to generate links. In the past, trying to develop relationships has gone nowhere. As a result, we're currently mostly creating good content ourselves and posting it on Web2.0 sites (weebly, etc.) and linking back to our site, and then using UAW (unique article wizard) to create a second tier of links to those links. We've been doing this for a while, and our traffic from SEO is going up - but we don't really know how to track our work. Can you please
a) give your opinion about our approach, and
b) tell me which metrics we should be using, and which tools for these metrics? Thank you so much
Greg0 -
Google Analytics Tracking Code Queries
Hello, I have taken on a new client who has Google Analytics installed. The tracking code is set to 'single domain'. Recently they added a mobile site using a sub-domain (m.website.com) which means that Google Analytics is not picking up this traffic. I want to revise the account so that I have a master account (raw data) and then profiles for the mobile site, main domain (www.website.com) and one other for a sub-domain that they are using. I am aware that there is mobile specific tracking code however I thought it would be easier (re conversions/goals/eCommerce tracking) to not use this and by changing the account to 'multiple domains' we could also get data for another sub-domain that they are using . My questions are: Am I right to want to use individual profiles over web properties. If not please explain why. When installing the tracking code (where the profile number is changing) I believe that I need to add that code with the changing profile number to the sub-domain sections. So my question is a) is that correct, and b) if I use a profile number on a sub-domain section will the master account still gather the data for the main URL as well as all sub-domains. If I change the master account from using 'single domain' tracking code to 'multiple domain' tracking code will this affect historical data? Will I lose the data? When changing from 'single domain' tracking to 'multiple domain' tracking does this affect eCommerce tracking? Or do we only need to be adding the additional lines of tracking code that allow sub-domains to be tracked? The web developers are using asynchronous code however half is in the and the other half is at the bottom of the source code. Given that traffic is being reported in the Google Analytics account should I have any concerns that the code is split? I have done a lot of reading but seem to be going around in circles, so your help is much appreciated! Thanks,
Reporting & Analytics | | Unity
Dinny0 -
Need Tips to Track Advertising of Domain on my Car
Hi, I'm working on building a new site. http://www.pilatesboisfranc.com/ I also bought the domain .ca (the business will be in canada) .net .org and .info All the domains are redirect to the .com This site is about my wife new business, a Pilates Studio. We would like to advertise the site on our personal car, using vinyl letters to display the domain name. Is there a way tu use the (.ca) http://www.pilatesboisfranc.ca advertise on my car and track that advertising using Analytics? I know I can use a URL something like http://www.pilatesboisfranc.com/health and track the hit, but using a shorter URL is the key. Can you help? Thank you, BigBlaze
Reporting & Analytics | | BigBlaze2050 -
What is best practice for tracking RSS feed subscribers
What is the most accurate/achievable way of tracking data about subscribers to your RSS feed through Google Analytics? With standard WordPress sites, we place the RSS link to Feedburner so we could track statistics. However it wouldn't track the way that I use it. I use Pulse on an Android Tablet to read my feeds offline on the bus each morning. At home, Pulse automatically downloads the latest feeds wirelessly overnight. So then I can read them without a connection. The obvious downside for my reading experience is that I only get what is contained in the feeds. If the company only includes an excerpt, it's too annoying to read the teaser and be unable to connect and follow a link. So I only subscribe to feeds that contain the full post. Yeah to seomoz, aimclear, SEL, adwordsblog. I dont subscribe to bruceclays blog, much as i'd like to, because it doesn't contain the full feed. That's probably deliberate on their part, because I have to consciously visit their blog on my desktop at work, to see the whole post. The other problem with say Pulse, is how it locates the feed. I typed in the URL, and Pulse subscribed me. I assume that Pulse simply looked for the domain.com/feed URL and added that, rather than look for feeds2.feedburner.com/domain. I looked at Feedburner stats and they didn't go up for 2 days, so basically it didn't track me. Would it be as simple as using the Google URL builder to add parameters to each post in the RSS feed? Eg utm_source=feedreader, utm_medium=rss, utm_campaign=tracking. But that still wouldn't track offline users. I assume that most people are also not going to paste the Feedburner URL into their FeedReader, but would let the platform auto-detect the feed. Any suggestions?
Reporting & Analytics | | ozgeekmum1 -
Tracking Effects of Internal Linking
Can anyone suggest the best way to track the effectiveness of internal linking on a website? Thanks!
Reporting & Analytics | | RishadShaikh590