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

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) 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']);

Note: 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.

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


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

    Note: 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”