We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Track Ajax Form Google Analytics

Medium Priority
785 Views
Last Modified: 2012-05-11
Hi All,

We have a simple callback form on a masterpage of our site. (i.e. so the for appears on every page).

Now we arelooking at setting up a goal in google analytics to track which page the user navigates and then track the form submission, which uses ajax.

Now can anyone help me to do this?

First of all, is there an easy way fr me to track all pages on the site? next I assume I need to add tracking code to the success part of the jquery ajax submission, how and what do I put here please?

i.e. so we could say the user entered at the contact page -> then illed the form in.

Thanks in advance,

Matt.
Comment
Watch Question

Tony McCreathTechnical SEO Consultant

Commented:
If your using the new async analytics then this JavaScript code would register a page view. So you can create virtual page views for places in your Ajax.

_gaq.push(['_trackPageview', '/Virtual-Page-Name']);

Or you could track things as events in Google Analytics with this sort of code:

_gaq.push(['_trackEvent', 'link', 'click', 'linkClicked']);

http://code.google.com/apis/analytics/docs/tracking/asyncUsageGuide.html
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Commented:
@AnalyticsNinja I tend to look at trackEvent for actions that wouldn't normally generate a page view, like controls on a video player.  

Submitting a non ajax form would normally dump a visitor to a thank-you page, so generating a page view would not be inappropriate.  

Is there an advantage to using trackEvent for form submissions that I am overlooking?
Tony McCreathTechnical SEO Consultant
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
ok sorry so would I take it I wouldnt' be adding the pageview to the master page (to disinguish between the pages??)

and then would add the event in te jscript ajax success method

_gaq.push(['_trackEvent', 'link', 'click', 'linkClicked']);

?

Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
The advantage of events over fake page views is that you can set-up a goal success rate based on an EVENT in GA v5. Also fake page views monkey with the base layer of data and muck up bounce rates.

I really wish people would not use fake pageviews and use events which are far more scalable,
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.