How to track Adobe Campaign URLs in Matomo
Adobe Campaign uses a single cid
URL parameter to encode multiple campaign values (e.g. campaign name, source, medium, keyword). This format differs from how Matomo expects campaign data, which relies on separate parameters like mtm_campaign
, mtm_source
, mtm_medium
, and mtm_keyword
.
By configuring either Matomo Tag Manager (MTM) or the Matomo JavaScript tracker, you can track Adobe Campaign URLs in the Matomo campaign reports. It allows you to preserve existing Adobe campaign links while maintaining accurate reporting within Matomo. This guide includes two configuration methods: using Matomo Tag Manager or the Matomo JavaScript tracker.
Implement only one method, depending on how you currently manage tracking on your site.
Configure Matomo Tag Manager
The configuration steps will refer to the following Adobe Campaign URL example: https://example.com/easterpromo.html?cid=se-easter2025:ch-web:sr-link:kw-easter
This contains:
se-easter2025
– campaign namech-web
– mediumsr-link
– sourcekw-easter
– keyword
Tracking these values in the campaign reports requires some parsing logic to extract each part of the cid
string and map it to the relevant campaign parameters.
Create a Custom JavaScript variable
The custom JavaScript function will convert the cid
parameter into Matomo-compatible values.
- Go to Matomo Tag Manager > Variables.
- Click Create New Variable and choose the Custom JavaScript Variable.
- Provide a meaningful name, e.g., Adobe URL Parser.
- Paste the following script in the JavaScript function field and save the variable.
Note: This script can be adapted to support other parameters.
function () {
const queryString = window.location.search;
const params = new URLSearchParams(queryString);
const cid = params.get('cid');
const finalURL = new URL(window.location.href);
if (cid) {
const splittedCid = cid.split(':');
const matchingParams = {
'se': 'mtm_campaign',
'ch': 'mtm_medium',
'sr': 'mtm_source',
'kw': 'mtm_keyword',
};
const campaignParams = {};
splittedCid.forEach(element => {
const campaignValue = element.split('-');
const key = matchingParams[campaignValue[0]];
if (key && campaignValue[1]) {
campaignParams[key] = campaignValue[1];
}
});
Object.keys(campaignParams).forEach(param => {
finalURL.searchParams.append(param, campaignParams[param]);
});
finalURL.searchParams.delete('cid');
}
return finalURL.href;
}
Set up a Pageview trigger with conditions
- Go to Triggers and click Create New Trigger.
- Choose the Pageview trigger and define a trigger condition. For example, Page URL contains easterpromo (for
/easterpromo.html?cid=se-easter2025:ch-web:sr-link:kw-easter
) - Save the trigger.
Set up the Matomo Analytics tag
- Navigate to Tags and click Create New Tag.
- Choose the Matomo Analytics Tag and use the default Pageview tracking type.
- Scroll down to the Custom URL field and select the newly-created variable, e.g., Adobe URL Parser.
- Link the Pageview trigger containing the Page URL trigger condition.
- Only one pageview tracking tag should fire per page. If you already have a pageview tracking tag in place, modify its trigger to exclude campaign-specific pages, e.g., Page URL not contains easterpromo.
- Save the new tag.
- Publish your Matomo Tag Manager container.
Configure the Matomo JavaScript tracker
To track Adobe Campaign URLs using the Matomo JavaScript tracker (instead of Matomo Tag Manager), you’ll need to parse the cid
parameter and convert it into Matomo-compatible campaign parameters using setCustomUrl
.
Modify the Matomo JavaScript tracker in the campaign-specific pages by placing a parsing script before the trackPageView
call in your Matomo tracking code. This extracts values from the cid
parameter and rewrites the URL (in Matomo reports) with mtm_campaign
, mtm_source
, mtm_medium
, and mtm_keyword
. For example:
<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
// Parse 'cid' and rewrite as Matomo campaign parameters
(function () {
const url = new URL(window.location.href);
const cid = url.searchParams.get('cid');
if (cid) {
const parts = cid.split(':');
const matchingParams = {
'se': 'mtm_campaign',
'ch': 'mtm_medium',
'sr': 'mtm_source',
'kw': 'mtm_keyword',
};
const campaignParams = {};
parts.forEach(element => {
const [prefix, value] = element.split('-');
const key = matchingParams[prefix];
if (key && value) {
campaignParams[key] = value;
}
});
// Remove original 'cid' and append standard Matomo parameters
url.searchParams.delete('cid');
Object.keys(campaignParams).forEach(param => {
url.searchParams.append(param, campaignParams[param]);
});
// Set the modified URL for tracking
_paq.push(['setCustomUrl', url.href]);
}
// Continue with standard tracking
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
})();
(function() {
var u = "https://mysubdomain.matomo.cloud/";
_paq.push(['setTrackerUrl', u + 'matomo.php']);
_paq.push(['setSiteId', '1']);
})();
</script>
<script src="https://cdn.matomo.cloud/mysubdomain.matomo.cloud/matomo.js"></script>
<!-- End Matomo Code -->
Add the full tracking code, including the parsing logic, only to the pages where Adobe Campaign URLs will be used (i.e. pages that include a cid parameter). On all other pages, use the default Matomo tracking code without additional modifications.
Test the configuration
Validate the integration by verifying that tracking is active and data is being sent to Matomo as expected. When testing, make sure tracking is not blocked by consent settings, ad blockers, or browser privacy features.
- If using Matomo Tag Manager, open the Preview and debug mode to test the configuration.
- Visit a page with a
cid
parameter (e.g.?cid=se-easter2025:ch-web:sr-link:kw-easter
). - Verify the trigger and tag fired as expected and the custom JavaScript variable is populated with the converted campaign URL.
- Open Developer Tools > Network tab.
- Filter for
matomo.php
and inspect the query string. The URL should now include Matomo campaign parameters,
https://example.com/page.html?mtm_campaign=easter2025&mtm_medium=web&mtm_source=link&mtm_keyword=easter
- Go to Matomo > Visitors > Visits Log and confirm that the visit to the campaign page is recorded.
- Check Acquisition > Campaigns to see campaign data appear over time.
Troubleshooting
The correct campaign values are not showing
- Only one Pageview tag should fire per page. Check that your default Pageview tag does not conflict with the Adobe Campaign configuration.
- Check the configuration of the Matomo Analytics tag that includes reference to the Javascript variable to convert the URL.
- Double-check the string parsing in your custom JavaScript variable.
- Verify the
matomo.php
request includes themtm_campaign
,mtm_source
,mtm_medium
, ormtm_keyword
parameters.
The browser still shows the original cid URL
- This is expected. The script modifies the tracking URL sent to Matomo, not the URL displayed in the browser’s address bar.
- If needed, you can add custom JavaScript to update the visible URL using
history.replaceState()
. However, this is optional and generally not recommended if you’re preserving Adobe Analytics compatibility.
For more details on common tracking issues and how to resolve them, see What should I do if data is not being tracked?
Next steps
- Analyse marketing campaign reports
- Create Segments (for your Adobe Campaigns)
- Define Goals and Funnels to track how your campaigns drive conversions
- Create and analyse Custom Reports