Recently we switched over our Google Analytics code to the new and improved asynchronous tracking code. The new async analytics code claims to provide more accurate visitor tracking and also allows you to put the tracking snippet higher in the page without delaying subsequent content from rendering.
Unfortunately, when we made the switch to analytics asynchronous, we couldn’t figure out how to migrate two essential things.
- The first was event tracking. Event tracking allows analytics to track when a particular link or promo (video/image) is clicked.
- The second was setting a goal from a form that is submitted via AJAX. Our sign up form submits via AJAX, and thus there is not a traditional thank you page.
No need to worry though, we figured it all out, and have both solutions. Watch the video tutorial below for a full detailed explanation.
Event Tracking Javascript Code Snippet
_gaq.push(['_trackEvent', 'Videos', 'Viewed', 'How It Works']);
Set Goal (Virtual Pageview) Code Snippet
_gaq.push(['_trackPageview', '/sign-up-complete.php']);




Nice work, thank you
This is really nice..the video was an added help
Thanks!!
[...] forms that are submitted by AJAX were no longer being tracked by Analytics. They came up with the solution and even produced a video on how to take care of these problems simply and [...]
[...] Tracking Events And Goals With Google Analytics Asynchronous en 619Cloud [...]
Cheers for the info on the virtual page view using the new GA code.
Justin, you’re a savior with this one. I can’t believe there is no explicit syntax example/description within code.google.com explaining how to set a virtual page view. Nice explanation!
Thank you. This is a huge help. Appreciate it guys.
Thanks, that was exactly what I was looking for. I make massive use of “virtual pageviews” mapped to goals, then to AdWords Conversions.
[...] Tracking Events And Goals With Google Analytics Asynchronous (619cloud.com) [...]
Hi Everybody…
Nice post… btw, I just modified the Google Analytics plugin for WordPress and added the new asynchronous tracking method… Please review my post about Asynchronous Google Analytics plugin for WordPress at http://www.minilibra.com/wordpress/plugins/analytics.html
Cheers
Bambang Sugiarto
Thanks for the tip! Hopefully Google will allow us to set Event Tracking as a goal or at least offer more information re: Virtual Pageview with async.
The topic is an issue I am trying to resolve, but why oh why make a video about it?
10 minutes into downloading the video and I am only half way through watching (I live in South Africa)
Everytime you say Aaaaam or errrm or ummmmm it is more data to download, how about writing yourself a script!
And it took me this long to find out that this video does not resolve my ajax issues. Video does not scan
Basically create a GA Goal and then create an advanced segment for it. If you have a unique “thank you page” for the event you want to track then that will be your Goal URL, if the confirmation/thank you message appears in the same page then you have to add JS code (step 1 in the post) to fire a virtual page and use the virtual page as your Goal URL.
Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here! It’s always nice when you can not only be informed, but also entertained!
- Josh
The information looks great. But i have a small doubt on setting goal for AJAX pages. Can we use the code
_gaq.push(['_trackPageview', '/sign-up-complete.php']);
with the analytics code instead of having it in the Javascript. will this work fine and track goals if i add in my website.
Super useful, thanks for sharing!
Thank you really nice….
Hello,
This has been so helpful, but I have a question. I feel like I am very close to being able to track this action. The only problem I am facing is that our developer did not create an extension to the end of the goal:
< a href="calc();" rel="nofollow" >
As you can see, track_tax_calc(1)does not have a extension.
Can I still submit the goal URL as:
/track_tax_calc(1)
?
Or do I need to get the developer to add an extension for Google to understand this. Any help or advice would be appreciated. Thanks in advance!
Jason
Jason,
When we tried it, we had problems with URLS without an extension. So, to be safe, it should be very easy for the developer to simply do: /track_tax_calc.php or /track_tax_calc.html
Thank you for taking the time to create the video as it’s been a great help and very easy to follow. Much appreciated.
Thanks a bunch for this! The video was a nice touch and helpful.
I’m not a fan of using virtual page views because it requires the filter hack to separate these values from true page views.
It is frustrating that Google do not allow native recognition of events in the goal funnel.
[...] Setting up a “Sign up” Goal. Source: 619cloud.com [...]
I’m working on this on one of our client’s site’s and it doesn’t seem to be working.
The idea is, the user clicks a button to get custom directions and google analytics should be able to track that.
I have tested the form myself and it hasn’t recorded any data.
Inside the jquery validation plugin it looks like this:
success:function()
{
//track in google analytics (Goal)
_gaq.push(['_.trackPageview', '/directions complete.html']);
}
thanks! Please feel free to contact me directly!
Thank you – the video on ajax analytics installed for ajax requests helped alot. cheers!
thank you very much, very useful information
Very helpful
thanks for the info mate, in your video you said you needed to give the virtual page view an extension – but on the last screen you forgot to add it
implementing now with gravity forms for wordpress – will let you know how i go.
[...] Where there are different page URLs for the steps in a goal (for example: … /newsletter-sign-up.html and /newsletter-sign-up/thankyou.html), you can set up goals without a developer/webmaster. This is pretty straight forward. Here is a good video on you tube that takes you through the steps to set up this type of goal. When your goal does involve Javascript & Ajax (i.e. the page URL doesn’t change when the page is submitted) then check this video out that describes how to implement goals on this type of web page builds. [...]