How to track Google Ads campaigns with Matomo

In 2016, Google Ads was the most popular ad service on earth. As a result, it may be your first source for ad spending. Are you interested in knowing whether you are making a profit out of it? Would you like to know how to track users coming from Ads with Matomo (Piwik) efficiently? This is what this article is about.

Google Ads

What you need to know about Google Ads

By default, each ad you create in Google Ads is not tracked. Even worse than that, every click on your ad is identified in Matomo as an organic result coming from Google with the following value: “Keyword not defined”.

To make it simple, if you do not track your Ads campaigns both your paid and organic traffic will be biased within your Matomo account. It will be impossible for you to measure your return on investment and it means that you are throwing your money down the drain.

In order to avoid this, we will show you how to track Google Ads traffic into Matomo.

How to track paid Google Ads campaigns into Matomo

If you want to analyse Google Ads campaigns within Matomo properly, you need to add additional tracking parameters to the final URL of each of your ads.

We recommend using the following tool to add the needed additional tracking parameters:

You will then be able to push additional data to Matomo such as:

  • mtm_campaign: the name of your ad campaign
  • mtm_kwd: the keyword associated to this campaign
  • mtm_source: the source of your campaign
  • mtm_medium: the type of source, in our case either cpc, cpm, cpa
  • mtm_content: the content of your ad
  • mtm_cid: a Campaign ID identifier for your ad, or Click ID identifier for the click

Please note: If you are using an older version of Matomo, you will need to replace the campaign paramater prefix with pk_ instead of mtm_

For example, in the latest version of Matomo 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.

You can find the up-to-date instructions for tracking Campaigns in Matomo here:

If your campaign URL looks like this:, your campaign URL will then look like this after adding the campaign parameters:

As each ad URL can be fired by different keywords and can correspond to different campaigns or headlines, you will need to customise the campaign parameters for each URL.

Customsing all of your URLs individually would take you a lot of time under circumstances. That’s why you should know, that each URL parameter can be filled automatically in AdWords with a feature called “Tracking template”.

Simplifying the campaign URL parameters with tracking templates

You can define tracking templates either at the account, campaign or ad group level. For example, by using a tracking template at the account level, all your campaigns will have the same landing page with the URL parameters you defined in the tracking template. By defining it at the campaign level, it means that all your ad groups within the campaign will have the same landing page and so on and so forth. Any tracking template defined in a campaign, will overwrite a tracking template defined at the account level.

Tracking template at the account level

To edit the template at the account level, you need to click on “Settings”, then click on the “Account” settings tab and define your tracking template pattern. For example:{lpurl}&pk_campaign=AdWords&pk_kwd=Your-Keyword&pk_source=google&pk_medium=cpc&pk_content=My-Ad-Headline

This will apply to all your URLs within your account. So it is only useful if your website domain is the same across all your ads. The URL parameter is compulsory here.

It can be limiting to have a static value for “pk_campaign” and “pk_kwd” so Google allows you to use dynamic insertion, such as follows:{lpurl}&pk_campaign={campaignid}&pk_kwd={keyword}&pk_source=google&pk_medium=cpc&pk_content={creative}

The “{keyword}” means that the data is automatically replaced with the keyword which fired the ad within your account.

Visit the following page if you want to know more about the different dynamic tags that Ads supports:

Tracking template at the campaign level

If you wish to define a tracking template at the campaign level, you will find this option within the “Campaign” settings under the campaign URL options:

Tracking template at the Ad Group level

You can also set it at the Ad Group level within the “Ad Group” settings:

As Google mentions: “If you set up URL options at the campaign level, ad group level, or ad level, those settings will override the account-level options“.

Now that your URLs are properly configured, you will be able to analyse Ads traffic performances within Matomo once a click is coming from those sources.

Did you like this article? If yes, do not hesitate to share it or give us your feedback about the topic you would like us to write about.s

Share this post