Analytics
5.6K members online now
5.6K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

Facing issues while tracking Analytics

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭
Hi,
 
We are facing issues while tracking Analytics, whenever we open any page from GA while looking for top 10 pages, the URL that shows up in the new window isn't correct. The URL that shows up with screenshot is mentioned below for your reference.
 
In short I'm getting baseURL+ whole page URL when I'm trying to click on Google Analytics Link. And this is happening for all the links. Is there any code change required?
 
We are passing parameter to your script through Javascript.
 
function trackPageViewed(){
   var strPageTitle = document.title;
   var strPageURL = document.location.href;
   /* if($('.allpageslist').length == 0){ */
   window.ga = window.ga || function () { (ga.q = ga.q || []).push(arguments) }; ga.l = +new Date;
   ga('create', 'UA-36468967-1', 'auto');
   ga('set', {
                  page: strPageURL,   //here we are passing page URL
                  title: strPageTitle       // here we are passing page title
     });
     ga('send', 'pageview');
//}
}
 
Please click on below link for screenshot:
 
 
 
 

Re: Facing issues while tracking Analytics

Follower ✭ ✭ ☆
# 2
Follower ✭ ✭ ☆

Hi Shripad B

 

Please change to the code following.

 

function trackPageViewed(){
  var strPageTitle = document.title;
  var strPageURL = document.location.href;
  /* if($('.allpageslist').length == 0){ */
  window.ga = window.ga || function () { (ga.q = ga.q || []).push(arguments) }; ga.l = +new Date;
  ga('create', 'UA-36468967-1', 'auto');
  ga('set', {
    location: strPageURL,   //here we are passing page URL
    title: strPageTitle       // here we are passing page title
  });
  ga('send', 'pageview');
//}
}

The "page" parameter is for representing the component without the domain name.

Besides, the "location" parameter is for representing the full url (without hash).