How to change the page path being reported to Google Analytics as a pageview I would like a certain page path to be reported as a different page path, IF it has a hash on it. 

/page-name#hash-name 


should be reported as 

/page-name/hash-name


Thing is that with the Google Analytics module I end up reporting two pageviews if I add this to custom js:

ga('send', 'pageview', '/pagename/' + window.location.hash.substr(1));
In the Google Analytics configuration (admin/config/system/google-analytics) under the collapsed fieldset "Advanced" > "Custom JavaScript code" there is a field "Code snippet (before)" where you can add javascript (pure, no jQuery).

In this case I added the following:

if(window.location.pathname === '/pagename') {
  if(window.location.hash) {
    ga('set', 'page', '/pagename/' + window.location.hash.substr(1));
  }
}


Essentially any Google Analytics variable can be pre-set or changed before the pageview fires.