I\'m trying to set up event tracking so that I can track when someone goes to my \'about\' page and clicks on a link to my LinkedIn profile. Below is the link that I want tracke
The problem is that the browser redirects to the new URL before the event has been properly recorded.
There are three common methods:
Bad: Insert a small delay before redirecting. This is an unreliable method because the delay required depends on the performance of the network. In a slow network, the event may not be recorded because the browser will switch to the new URL too soon.
Better: Add target="_blank"
to your element. This will open the link in a new window, and will allow the event to be logged because the old window will stay open.
Best: The ga()
method allows a callback function to be run immediately after the event has been successfully recorded.
Usage:
Check out example.com
The code above was copied from this page.