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 Add a tag.
- Name the tag and select the following type: Custom code (async).
- Click Next.
- In Tag code, type the following code:
<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 Tag triggers, click Add a trigger.
- Name the trigger.
- In Trigger type, choose the following type: Page view.
- In Event conditions, define conditions for the trigger. In our example,
Page URL equals https://clearbank.com.
- When you’re done, click OK.
- Click Save for the tag.
- Test your tag in debug mode.
- 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.
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.