Advanced: How to Manually Build Campaign Tracking URLs
Campaign Tracking URL Structure
It is useful to be able to recognise the components of a campaign tracking URL. With this knowledge, you can type your own or at least verify automatically generated tracking links.
The image above shows an example campaign tracking URL with the campaign tracking components highlighted in different colours. In order, the components of a campaign tracking link are:
- Standard URL (Shown in Black): The destination of the link.
- ? or # Symbol (Shown in Gray): This is a standard method for adding data to links.
- Parameter Name (Shown in Orange): These define which campaign tracking parameter is being used.
- = Symbol (Shown in Gray): Separates the parameter name from its value.
- Parameter Value (Shown in Blue): The campaign value to be tracked in Matomo.
- & Symbol (Shown in Gray): Used to separate additional campaign tracking parameters.
Components 3-6 can be repeated for as many campaign tracking parameters as are needed from the eight available. You don’t need to add an ampersand “&” symbol after the final parameter. Below is an example link using all eight campaign tracking parameters:
Alternative Campaign Tracking URL Configurations
URL Fragment Tracking
Campaign tracking values are typically set via query parameters on your URL. This means the first parameter is preceded by a ? and each subsequent parameter is separated by the & symbol. For example:
However, some content management systems may use standard query parameters for navigation. In those cases, it can be safer to use the alternative fragment system by adding campaign parameters after a # symbol, with each subsequent parameter separated by an & as shown below:
Campaign Tracking Compatibility with Alternative URL Parameters
Campaign tracking is a popular tool used across millions of websites, so there are a few alternative implementations in use. Luckily Matomo has been built with this in mind and supports all of the most popular alternatives out of the box. This means if you have been using campaign tracking links with another tool, it will likely work automatically, and if not, there is the ability to add your own.
When creating new links with Matomo Cloud or self-hosted versions of Matomo from version 4.0 and above, it is recommended you use the standard
mtm_ prefix, as in
mtm_campaign. However, for support of alternative and older implementations, the following prefixes will also be recognised in place of the standard
For example, the following parameters are all recognised and accepted by default for the Campaign tracking parameter:
piwik_ were the parameters used in older versions of Matomo (3.x and below) and Google Analytics uses
utm_ . If you are already using campaign tracking URLs with parameters that are not recognised by default, then it is possible to customise your Matomo instance to accept additional parameters.