Remove parts of the URL being tracked

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?

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: https://www.mooash.me/2014/08/12/set-custom-title-url-piwik/
Cheers,

1 Like

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