Page name issue

cathyw49544988

19-12-2017

Hi, I am trying to create page name based on URL. I modified the URL and form the page name. I did some changes like:

1. remove www.

2. remove.html

3. change / to |

Then I run into a very strange issue. For example a page, 5034 times the page name was correct. But 136 times, the page name showed wrong. somehow all the '-' disappeared and replaced with space. I checked the URL for those pages were correct. I am wondering anyone has any idea maybe what caused this?

Thanks,

-Cathy

Accepted Solutions (0)

Answers (14)

Answers (14)

joshd7227840

MVP

20-12-2017

Okay well I don't see anything in this code that directly replaces anything with a space. My next guess is the dataLayer[0]['pageURL'] variable you reference sometimes has spaces in it.  Maybe whatever outputs this data layer variable has it when it is output sometimes. Or maybe there is some other code elsewhere that alters it sometimes. Or, maybe you have other code elsewhere that sets your page name using different code, that executes/overrides this code, sometimes.

I'm not sure what more I can really do to try and help without at least a link to the site to poke at. If you can provide a link to the site (ideally, a page where you see this happening in the reports), I can try and dig deeper into it, but you're definitely getting into "need to be a real coder to QA this" territory. Things like outputting console logs at specific points in DTM, adding breakpoints/watches on variables in the js console.. not really feasible to try and walk you through that stuff on the forums..

Sidenote: At face value it looks like you are piggybacking off of Google Tag Manager's (GTM) dataLayer array.  This is generally a bad idea.. mainly because unlike most data layer conventions, GTM pushes data layer states to an array, and there's no guarantee which element in the stack is the one you actually want for a given event. For example I assume you reference dataLayer[0] with the assumption it will contain relevant page view data from initial page load. Well there's no guarantee this will always be the case with GTM.  This logic also kinda gets tossed out the window if you have SPA pages, because you are effectively only looking at original full page load data (assuming its even first in the queue).

cathyw49544988

20-12-2017

I used Custom Script. The code is as following. Thanks for your help.

var page;

var locale;

if(typeof dataLayer != "undefined" && dataLayer != null ){

  if(typeof dataLayer[0]['locale'] != "undefined" && dataLayer[0]['locale'] != null ){

    locale = dataLayer[0]['locale'].toLowerCase();

    locale = locale.replace(/_/, '-');

  }

  else{

    locale = 'locale can not find';

  }

  if(typeof dataLayer[0]['pageURL'] != "undefined" && dataLayer[0]['pageURL'] != null ){

    page = dataLayer[0]['pageURL'];

 

    if( page.indexOf('www.mycompany.com') != -1 ){   

        page = page.replace(/www.mycompany.com\//, '');

       page = page.replace(/www.mycompany.com/, 'Home');

        page = page.replace(/index.html/, 'Home');

    }

    else{

      page = page.replace(/www./, '');

    }

    page = page.replace(/.html/, ''); 

    page = page.replace(/\//g, '|');

  }

  else{   // can not find URL in dataLayer

    page = getNonAEMName();

    }

}  

else{

  page = getNonAEMName();

}

return page;

function getNonAEMName(){

  var value = [location.host, location.pathname].join('');

  value = value.replace(/www./, '' );

  value = value.replace(/.html/, ''); 

  value = value.replace(/\//g, '|');

  return value;

}

cathyw49544988

19-12-2017

Another I want to add is, I used data element to translate the pageName. in the pageload rule, I assign the pageName dataelement value to Page Name variable and also to eVar6 and prop6. Right now, all of those 3 all have the wrong value. To me, the problem happened at data element level. So I think we can rule out the possibility of processing rules. Actually I don't have a lot of processing rules. I already checked. And in DTM, I don't have  a page load rule for mobile device ....... Is there anything else I can check?

jantzen_belliston-Adobe

Community Manager

19-12-2017

Testing on a mobile device requires the use of a proxy. The other option would be to have Customer Care pull a debug log to see what the raw hits were. Do you have the ability to open a ticket with Customer Care?

cathyw49544988

19-12-2017

I can not re-produce this issue. I tested the same page on laptop and everything is correct. I don't know how to test this on mobile device since I don't have debugger installed.

jantzen_belliston-Adobe

Community Manager

19-12-2017

It could also be something within Analytics changing the value. For example, processing rules. Are you able to reproduce the results on your site and view the beacon being sent by Analytics? If so, you could check the beacon for what is being sent. If what is being sent, matches what you see in reporting, processing rules is not changing the value.

joshd7227840

MVP

19-12-2017

As mentioned, there is nothing in the Adobe libraries that would replace "-" with " ". The only thing related I can think of is "+" is a form posted urlencoded character for " " if you have spaces in a URL, so e.g. "www.somesite.com/foo+bar/page.html?a=some+thing" would get decoded to "www.somesite.com/foo bar/page.html?a=some thing".  There are other special characters in a URL that are encoded/decoded, but "-" has no special meaning in the URL so it would never be changed to/from anything from any automated encoding/decoding.

So, sure, it's possible you have code on your site that swaps "-" for " " only on mobile devices, but it would be custom code on your site that someone implemented; not something coming from Adobe libraries.

joshd7227840

MVP

19-12-2017

By default, Adobe Analytics reports the page URL for pageName value if you do not set a pageName value yourself. Neither Adobe Analytics library nor DTM do anything to alter your pageName value without custom code written by you. So, somewhere on your site you have code doing this. 

Based on the low volume, it sounds like it could be buried in some random page load rule that doesn't trigger very often. Or, perhaps you have a legacy implementation using s_code.js that was never migrated to DTM.  Also possible you might have some AB/MV testing on pages that output diff pageName values.  Or maybe you have server-side code outputting a value that overrides in some cases.

Long story short, there are a number of reasons this could happen, but can't really say for sure what it is sight unseen.. so, maybe the above might help nudge you in the right direct. Or, if you can post an example page where you see it show up in the reports, we might be able to dig a little deeper.

cathyw49544988

19-12-2017

After I did further analysis and I noticed that all the issues happened on mobile systems and most of the OS were Google Android.  Anyone have suggestion how to handle this issue?

Thanks