There is a serious problem connecting Google Analytics event tracking to a hyperlink on a page (as shown in the documentation).
Example:
<a href="http://www.example.com/" onclick="_gaq.push(['_trackEvent', 'Links', 'Click', 'Example Link']);" > Example! </a>
When a user clicks on such a link in the Google Chrome browser, GA starts sending a request to the server (event tracking), but the browser also starts loading another page (via the link), and the GA request is “canceled”, so the event does not reach the server GA and not displayed in statistics.
How can we resist this?
For example, we can delay navigation to the linked page until the event reaches the GA server, but how can we do this if GA requests are asynchronous and we cannot find any callback functions in the documentation.
Is there a way to get notified when a pressed command is executed?
source share