How to use custom page titles
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:
- Go to Menu > Tag Manager.
- Navigate to Tags.
- Click + Create new tag.
- Name the tag and choose Custom asynchronous tag template.
- In Tag HTML code, type the following code:
- In Tag triggers, click + New trigger.
- Name the trigger.
- In Event type, choose the page view trigger.
- In Trigger conditions, define conditions for the trigger. In our example,
Page URL equals https://clearbank.com.
- When you’re done, click Save for the trigger and click Save for the tag.
- Test your tag in debug mode.
- When you’re happy how the tag works, click Publish.
<script> _paq.push(['setDocumentTitle', "Custom page title"]); _paq.push(['trackPageView']); </script>
"Custom page title" with the title that you want to use. You can also use a variable here.
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, in the page report (Menu > Analytics (new) > Reports > Pages)
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, contact us at firstname.lastname@example.org, and we’ll come up with a custom solution for you.