How to use custom page titles

Analytics + Tag Manager

Sometimes page titles are not clear in reports, and you want to tidy them up. By default, Piwik PRO takes the page title from document.title, which is the text content of the <title> element in the page’s source code. But these titles may be too long for you, have too much information or, in case of single-page applications, they may not change as the page content changes. In that case, you can create a custom page title that will appear in reports but won’t change the original title on the website.

Let’s say we have two page titles that we want to customize.

Page URL Page title Custom page title
clearbank.com Clear Bank | Best mobile banking app Home page
clearbank.com/product-tour Product tour | Clear Bank | Better mobile banking app Product tour

To create a custom page title, follow these steps:

  1. Go to Menu > Tag Manager.
  2. Navigate to Tags.
  3. Click Add a tag.
  4. Name the tag and select the following type: Custom code (async).
  5. Click Next.
  6. In Tag code, type the following code:
    <script>
        _paq.push(['setDocumentTitle', "Custom page title"]);
        _paq.push(['trackPageView']);
    </script>

    Replace "Custom page title" with the title that you want to use. You can also use a variable here.

  7. In Tag triggers, click Add a trigger.
  8. Name the trigger.
  9. In Trigger type, choose the following type: Page view.
    Page view trigger in Piwik PRO
  10. In Event conditions, define conditions for the trigger. In our example, Page URL equals https://clearbank.com.
    Page view trigger in Piwik PRO
  11. When you’re done, click OK.
  12. Click Save for the tag.
  13. Test your tag in debug mode.
  14. When you’re happy how the tag works, click Publish.

In our example, we would repeat this process for the other page to change its title. After that, we would see custom page titles in the reports, for example, under Menu > Analytics > Reports > Pages.

Page report in Piwik PRO with custom page titles.

Note: There are other methods to customize page titles, but the one described in this article is the simplest. In advanced cases, you may need to adjust your tracking code and use a virtual page title with a variable. If you run into such an issue, ask a question on our community forum.

Was this article helpful?

Technical support

If you still have some questions, visit our community.
There’s always someone ready to help!

Back to help center