Trailing slashes sometimes removed

For certain page paths, it looks like the trailing comma is being removed sometimes but not others. For example:

Is there any way to combine page paths like this so it only shows page paths either with trailing slashes or without?

Hi @Rachel_Witner,

Short answer: It’s not possible to change values of dimensions after they were already tracked, but it’s possible to add/remove the slash before sending the data to Piwik PRO.

Why slashes appear sometimes and sometimes they don’t: Both /fragrance-oil-finder and /fragrance-oil-finder/ will point to the same page on your website, because of that visitors sometimes will use one and sometimes the other one. To minimize the usage of one of them you have to make sure that all links in your website use particular standard either ending the path with “/” or without it.

How to send data to Piwik PRO with particular standard: With custom setup it’s possible to check each URL and remove the slash or add it (depending on what standard you’d like to use) before sending the tracking request.

Here’s how to achieve that (solution for adding missing “/” at the end):

  1. Go to Menu → Tag Manager → Tags

  2. Click on Add a tag and give it a name.

  3. Select Custom code (async) and click Next

  4. Use this script:

<script>
    var _paq = _paq || [];
    (function(){
      var urlArr = {{ Page Url }}.split("?");
      if(urlArr[0].slice(-1) !== "/") urlArr[0] += "/";
      if(urlArr.length > 1) _paq.push(["setCustomUrl", urlArr[0] + "?" + urlArr[1]]);
      else _paq.push(["setCustomUrl", urlArr[0]]);
    })();
</script>
  1. In Tag triggers click on Choose existing trigger and select the All page views trigger
  2. Add this tag by clicking on OK button.
  3. Go to Menu → Tag Manager → Settings → Tag priority
  4. Select the new created tag and put it as first in priority. To make sure everything works fine right after it add a Piwik PRO tag.

This solution will work only on new data and will not change the already gathered one.

Best,
Oliwer

1 Like