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.

Campaign Tracking URL

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:

  1. Standard URL (Shown in Black): The destination of the link.
  2. ? or # Symbol (Shown in Gray): This is a standard method for adding data to links.
  3. Parameter Name (Shown in Orange): These define which campaign tracking parameter is being used.
  4. = Symbol (Shown in Gray): Separates the parameter name from its value.
  5. Parameter Value (Shown in Blue): The campaign value to be tracked in Matomo.
  6. & 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:

https://example.com/?mtm_campaign=email_sale&mtm_source=newsletter&mtm_keyword=campaigns&mtm_medium=email&mtm_content=example_link&mtm_cid=1234&mtm_group=customers&mtm_placement=footer_banner

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:

https://example.com/?mtm_campaign=documentation&mtm_keyword=demo

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:

https://example.com/#mtm_campaign=documentation&mtm_keyword=demo 

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 mtm_ prefix:

  • matomo_
  • pk_
  • piwik_
  • utm_

For example, the following parameters are all recognised and accepted by default for the Campaign tracking parameter:

  • mtm_campaign
  • matomo_campaign
  • pk_campaign
  • piwik_campaign
  • utm_campaign

Both pk_ and 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.

Previous FAQ: Analyse marketing campaign reports