views:

165

answers:

3

I have an overlay with form (just a radio button group with 3 buttons and a submit button) that, on submit, uses jQuery to open a specific file (a PDF) in a new tab and then close the overlay. The file depends on which button was selected. The problem: the form doesn't actually submit so I don't know how to track submissions, and the client wants to know the percentage of people clicking each button.

How can I track that? I can't track actual submissions because obviously nothing gets POST'ed or GET'ed, and I can't track Google Analytics clicks because GA only tracks clicks on links, not on form buttons.

Any ideas? Is this enough info? I can post the code, but it involves cookies and Thickbox and would just add more confusion to anyone trying to understand the situation.

+1  A: 

Have the submissions trigger a javascript function that 1) fires off an ajax update to the server (to indicate a click) and 2) opens the PDF.

Or

Have the form add a querystring to the request for the PDF, and analyze your log files to track those querystrings.

JacobM
A: 

When you trigger your form submission and JQuery opens the file, you could simultaneously make an AJAX request to a tracked URL.

[Edit] Sorry, this answer is woefully unclear. As per the comment below, the URL to which you're sending the AJAX request would have to be tracked serverside, since scripts would not be run when the page was requested with XmlHttpRequest. So google analytics would not work in this example.

Travis
An XHR to an HTML page won't run the scripts on it.
Török Gábor
+3  A: 

Function _trackPageview()—that is part of the standard tracking code you embed in your web pages—could be also called with an argument string at anytime to generate a virtual page request for Google Analytics.

Google Analytics' _trackPageview is a function for use on ga.js tracked sites that allows you to track events on your site that do not generate a pageview. Using the _trackPageview JavaScript, you can assign a specific page filename to Flash events, JavaScript events, file downloads, outbound links, and more.

For further details see article How do I track JavaScript events? in Google Analytics Help Center.

Török Gábor