I'm trying to expand on an idea from someone else's question, and running into difficulty.
The idea is to insert the utm_source (from an ad campaign) into the url hash dynamically, have Google Analytics track the page, and then remove the hash. (We don't want to keep the hash because: 1. it's a duplicate page, and 2. If the user bookmarks it and comes back, it looks like another ad click)
Here's the code that almost works:
// save the old hash var campaignSource = "Some Banner Ad"; var oldHash = document.location.hash; // add campaign data to the hash document.location.hash = 'utm_source=' + escape(campaignSource); pageTracker._setAllowAnchor(true); pageTracker._trackPageview(); // restore the old hash: document.location.hash = oldHash;
The caveat is that it adds two more entries to the history (back button) on each change.
The question: How can I make the browser skip the history for hash changes?