Reputation: 79
I've been using Google analytics trackPageview for a while and recently used the following js function to track some form submit button, which is to grab the current url and add some parameters to it. Things work fine, except that the URL that I see in the report is /https://www.mysite.com?pg=confirm (with a forward slash at front), instead of https://www.www.mysite.com?pg=confirm as I wanted. How to remove that slash? Thanks!
function trackGoogle(btn){
var curl = document.URL;
var confirm_url;
if (btn == 1){
confirm_url = curl + '?pg=confirm';}
else {confirm_url = curl + '?pg=confirm';}
_gaq.push(['_trackPageview', confirm_url]);
}
Upvotes: 0
Views: 888
Reputation: 654
Analytics generates your pageview reports relative to the site's root for the property/profile you're viewing. The confirm_url
parameter you're passing to GA is assumed to be the relative path (excluding the domain) from the site's root. In other words, the preceding slash stands for "www.mysite.com" and so confirm_url
should be "?pg=confirm"
Upvotes: 1