Remove parts of the URL being tracked


#1

We are trying out Piwik in a Websphere Portal site, and want to remove everything after /!ut/ to not be tracked, since it contains session and portlet state information.

I read on the forums that it would be possible to use: piwikTracker.setCustomUrl(‘yoursite.com’); But it looks like this is through the use of the API. I am using the following script instead:

var _paq = _paq || [];
<portal-logic:if loggedIn="yes">
<c:set var="mail"><portal-fmt:user attribute="mail"/></c:set>
_paq.push(['setUserId', '${mail}']);
</portal-logic:if>
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
  var u="//xxx.xxxxxx.xxx/";
  _paq.push(['setTrackerUrl', u+'piwik.php']);
  _paq.push(['setSiteId', 1]);
  var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
  g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();

How to include this param in the _paq.push variable?


#2

Hi, you simply need to add a line like this:
_paq.push([‘setCustomUrl’, ‘http://example.com/’]);
before the trackPageView line so your code should look something like this:

var _paq = _paq || [];
<portal-logic:if loggedIn=“yes”>
<c:set var=“mail”><portal-fmt:user attribute=“mail”/></c:set>
_paq.push([‘setUserId’, ‘${mail}’]);
</portal-logic:if>
_paq.push([‘trackPageView’]);
_paq.push([‘enableLinkTracking’]);
(function() {
var u="//xxx.xxxxxx.xxx/";
_paq.push([‘setTrackerUrl’, u+‘piwik.php’]);
_paq.push([‘setSiteId’, 1]);
var d=document, g=d.createElement(‘script’), s=d.getElementsByTagName(‘script’)[0];
g.type=‘text/javascript’; g.async=true; g.defer=true; g.src=u+‘piwik.js’; s.parentNode.insertBefore(g,s);
})();

There is a nice article describing this in detail here: Set a custom page title and URL in Piwik - James Loh
Cheers,


#3

Thanks, this was what I was looking for :slightly_smiling: