About
A canonical is a short unique path identifier for a page on your website.
Usage
Named permalink
The canonical is used to create a named permalink in order to get quickly to a page without knowing its full path
Example:
https://yourdomain.com/your/canonical
Canonical Url
The canonical path can be used as path in the canonical url.
Tracking Metrics
The canonical path can be used in your tracking metrics in order to aggregate the page view even if the page:
- is accessed via different url
- or has moved
You can:
- enable it via the Google Analytics pageview configuration
- or integrate it in your actual tracker. See the javascript example, to know how to access this value from your page.
Value
The canonical path should have a meaning and be understandable by humans.
The canonical value:
- should be unique for all pages of your website (ie domain).
- should be written as wiki path (ie with a : semi-colon as path separator)
- does not need to be the page path
- is always lowercase
Demo
This page has the canonical value set to canonical and therefore is also available at the following named permalink. https://combostrap.com/canonical
You can try it your self.
Navigate to this page via its canonical URL !
or
How to set the canonical value ?
Manually
To set the canonical value, uses the metadata manager and set the canonical property in a wiki path format (ie the path separator should be a colon)
Example:
my:path
Automatically
You can also create a canonical value based on the last parts of a page path. See Automatic Canonical Path
Javascript Example
If you want to retrieve the canonical value to add it to your tracking_metrics, you can access it via the JSINFO javascript variable.
Example:
console.log(`The canonical for this page is '${window.parent.JSINFO["canonical"]}'`);
Configuration
Google Analytics
You can send the canonical path as page identifier to Google Analytics.
For further information, see the Google Analytics Pageview section