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 -
Filter Tracking works fine at staging site but not on LIVE site why?
Hello Expert, For my ecommerce site I want to track filter url's like price range, size, width, color etc and fully filter url should display in google analytic. I have implemented filter tracking at staging server and it works perfectly but on LIVE site it not show me full filter url. Do you guys think any parameter which i have configured in search console affect this? Note - I have configured in this way - http://webmasters.stackexchange.com/questions/93008/how-to-track-a-product-filter-in-the-product-list-view-with-google-analytics My filter url's are given below. And in search console I have configure two parameters. 1) effect - Sort, Crawl - No urls 2) FT - effect- ( - ) , crawl - Let google bot decide. But as per me this parameter is for crawling should not affect tracking right? mysite.com?FP=0&filtSeq=Price&Sort=BS
Reporting & Analytics | | adamjack
mysite.com?FT=7581&filtSeq=Type&Sort=BS
mysite.com?FT=1042&filtSeq=Colour&Sort=BS In robot file nothing is block. In analytic it showing me url till mysite.com only where as in staging it shows me full filter url. Thanks!0 -
Tracking 301 redirect traffic in Google Analytics
if I 301 redirect www.mywebsite.com to go to www.yourwebsite.com, how can I track the traffic in Google Analytics that is coming from mywebsite.com?? I don't think that's a referral traffic, is it?
Reporting & Analytics | | Armen-SEO0 -
How to trigger a pageview using Google Analytics API upon form submission
I need to set up a goal using the G A API to trigger a pageview when someone submits a lead on my site. There's no "thank you"page currently. How do I go about it? There's no "thank you"page currently. How do I go about it? I have never used the API but am very familiar with analytics. Thanks!
Reporting & Analytics | | Majsan0 -
Tracking time spent on a section of a website in Google Analytics
Hi, I've been asked by a client to track time spent or number of pages visited on a specific section of their website using Google Analytics but can't see how to do this. For example, they have a "golf" section within their site and want to measure how many people either visit 5 page or more within the golf section or spend at least 6 minutes browsing the various golf section pages. Can anyone advise how if this can be done, and if so, how I go about it. Thanks
Reporting & Analytics | | geckonm0 -
Set Up of Goal Tracking with Google Analytics-$750 a Fair Price????
Greetings Moz Community! My firm operates commercial real estate website that contains 3-4 forms. Each form represents a goals. Google Analytics has been set up for years, but it does not track these form completions/goals properly. My SEO firm has offered to configure Goals on Google Analytics for $750. Is this a fair price? If the set up takes one hour, I am really over paying. But if this is a complex project that may take 7-9 hours the pricing seems OK. Also, the SEO firm will require an additional $750 in the future to set up event tracking. Is this excessive? I might add that my developer will need to add code to my web site. My SEO company has proven reliable and accurate. I can go to sleep at night knowing they are doing a good job. Where as my Argentinian developers really try their best, but perhaps because of the language barrier, they can make mistakes from time to time. I am willing to pay a premium to ensure that the job is done correctly domestically, however I don't appreciate over paying. Is the $750 payment for setting up Google Analytics reasonable assuming the job is done well??? Thanks,
Reporting & Analytics | | Kingalan1
Alan0 -
Ga event tracking and GAC code placement
Just relaunched website and since then specific event tracking has zeroed. I copied event tracking directly from old site so it should work. Overall analytics are fine. Only variable I can think of is where google analytics code is placed. Does GAC code need to be on HTML header or at end of body specifically for event tracking to work? Example: Steripen.com/freedom/... When user clicks "REI" icon, this tracks an event that a user clicked on one of our"retailer links." Any feedback is greatly appreciated.
Reporting & Analytics | | Timmmmy0 -
Google Analtyics Cross Domain Tracking - in a form
I have a 3rd party booking engine that is causing my own domain to show up as a top referreral in google analytics. The vendor is on my very last nerve 🙂 So they're not helping. Would anyone be interested in helping a newbie out with a frustrating problem? Code: Reservations Page - function SubmitReservationForm() {. . . .
Reporting & Analytics | | jenny05
ResLink = "http://www.bookingengine.com/res/vn4/checka.aspx?month=" + Month + "&day=" + Day + "&year=" + Year + "&nights=" + Nights + "&rooms=" + Rooms + "&adults=" + Adults + "&children=" + Children + "&B1=Check+Availability&hotelid=xxxx"
pageTracker._link(ResLink);
return true;
} On Every page: Any thoughts would be appreciated! I believe the problem is pageTracker._link(ResLink); but I'm clueless on fixing it.1