By default, tracking campaigns in Matomo (Piwik) involves adding the required parameter pk_campaign (and optional parameter pk_kwd) to the URLs pointing to your website. Matomo also supports Google Analytics campaign parameters (utm_*).

Here is a comma delimited list of default parameter names that Matomo will read:

 campaign name parameters: mtm_campaign, matomo_campaign, pk_campaign, piwik_campaign, utm_campaign, utm_source, utm_medium
 campaign keyword parameters: mtm_kwd, mtm_keyword, pk_kwd, piwik_kwd, pk_keyword, utm_term

It is also possible to customize these parameter names. For example, we would like to use the parameters names “campaign” (instead of pk_campaign) and “keyword” (instead of pk_kwd). To do so, there are two required steps:

  • 1) Override the parameters in the config file. In your config/config.ini.php, add the following:

    [Tracker]
    campaign_var_name="campaign"
    campaign_keyword_var_name="keyword"
    

Note: you may specify a comma separated list of campaign parameter names, in case you wanted Matomo to read the campaign name or value from several possible parameters. The first non empty value will be used.

  • 2) Customize the parameters in the Javascript. In the Javascript snippet on all your pages, add the following before the trackPageView() call:

    _paq.push(['setCampaignNameKey', 'campaign']);
    _paq.push(['setCampaignKeywordKey', 'keyword']);
    

Notes:

  • these two functions also accept an array of strings. If an array of names is specified, the first non empty campaign or keyword parameter value will be selected.

  • the Campaign parameters can be used in the query string or in the hash as well (for cleaner canonical URLs), such as: “landing.html#pk_campaign=my campaign”

  • to measure more than campaign name and keyword and up to five campaign dimensions, as well as support other standard UTM campaign tags, use the free plugin MarketingCampaignsReporting

  • to find out the true value and success of all of your marketing campaigns, we recommend using the Multi Channel Conversion Attribution premium feature.

You may also be interested in creating an affiliate system with Matomo to track new customers and revenue from affiliates.

Previous FAQ: URL Builder – Marketing Campaign Tracking