Skip to content

Commit 8dc4e1f

Browse files
Merge pull request #857 from plausible/utms
utms
2 parents 1b03bd6 + f885c9a commit 8dc4e1f

5 files changed

Lines changed: 41 additions & 2 deletions

File tree

‎docs/compliance.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ The specific reasons it falls into this category:
3232

3333
If your privacy policy needs to offer visitors a way to object to analytics, you can add a ready-made opt-out page to your site and link to it from the policy. [See how](excluding-localstorage.md).
3434

35+
## Keeping campaign parameters out of your stats
36+
37+
Plausible records UTM tags and the address of the referring page by default. If your review needs them left out, you can remove them in the tracking snippet before anything is sent. [See how](stop-tracking-utm-tags.md).
38+
3539
## Security questionnaires
3640

3741
If your organization requires a vendor security review, the documents above are designed to answer the questions typically asked in those reviews. We recommend going through them before sending a questionnaire, as most topics are already covered.

‎docs/script-extensions.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ This means that pages like `yoursite.com/blog/index.php?article=some_article&pag
9595

9696
By using the manual script extension, you can also track custom query parameters and get the complete page URLs in your **Top Pages** tab. Learn here [how to do that](custom-query-params.md).
9797

98+
#### Stop tracking UTM tags and other query parameters
99+
100+
If you'd rather not record UTM tags, click IDs or the referring page's address, you can remove them with `transformRequest` before anything is sent. Learn here [how to do that](stop-tracking-utm-tags.md).
101+
98102
:::tip Want to track outbound link clicks or file downloads cloaked with pretty URLs?
99103
See these [step-by-step instructions](custom-automatic-link-tracking.md) for how to do that.
100104
:::

‎docs/stop-tracking-utm-tags.md‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Stop tracking UTM tags and other query parameters
44
description: "How to stop Plausible from tracking UTM tags and other query parameters by stripping them from the URL before the pageview is recorded."
55
---
66

7-
By default, Plausible strips all query parameters for privacy purposes [except for](top-referrers.md) `ref`, `source`, `utm_source`, `utm_medium`, `utm_campaign`, `utm_content` and `utm_term`. If you prefer to stop tracking these parameters as well, please follow these instructions:
7+
By default, Plausible strips all query parameters for privacy purposes [except for](top-referrers.md) `ref`, `source`, `utm_source`, `utm_medium`, `utm_campaign`, `utm_content` and `utm_term`, and it also reads ad click IDs such as `gclid` and `msclkid` to recognise paid search traffic. If you prefer to stop tracking these parameters as well, for example to follow stricter national guidance on audience measurement, please follow these instructions:
88

99
## Set `transformRequest` option in `plausible.init`
1010

@@ -29,7 +29,27 @@ plausible.init({
2929
})
3030
```
3131

32-
That's it! You're now no longer tracking any UTM tags or other parameters. We will use the [referrer header](top-referrers.md) to display the sources of the traffic instead. If the referring site doesn't send any referrer header, the traffic will fall within the "Direct / None" source.
32+
That's it! You're now no longer tracking any UTM tags or other parameters. We will use the [referrer header](top-referrers.md) to display the sources of the traffic instead. If the referring site doesn't send any referrer header, the traffic will fall within the "Direct / None" source. Without UTM tags and click IDs, visits from paid campaigns are counted under their source, such as Google, rather than as paid traffic in the **Channels** report.
33+
34+
## Keep only the referring domain
35+
36+
The referrer header can include the full address of the page a visitor came from. If you'd rather record only the referring site, also replace the referrer with its domain in the same `transformRequest` function:
37+
38+
```javascript
39+
function transformRequest(payload) {
40+
payload.u = queryStrippedUrl()
41+
if (payload.r) {
42+
try {
43+
payload.r = new URL(payload.r).origin
44+
} catch (e) {
45+
payload.r = null
46+
}
47+
}
48+
return payload
49+
}
50+
```
51+
52+
Your **Sources** report keeps working as before. Only the page paths shown when you click on a source are no longer recorded.
3353

3454
:::note
3555
This solution may not work in single-page-applications or when using [hash-based routing](/hash-based-routing) as `location.href` may change before `transformRequest`

‎docs/top-referrers.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ Are you running paid marketing campaigns on Facebook, Google and other ad platfo
9999
* `utm_content`
100100
* `utm_term`
101101

102+
If you'd rather not record these parameters, you can strip them before they're sent: [Stop tracking UTM tags and other query parameters](stop-tracking-utm-tags.md).
103+
102104
Here's an example of how to tag your links: `yourdomain.com?utm_source=adwords&utm_medium=ppc&utm_campaign=novemberoffer&utm_content=sustainability&utm_term=discount`
103105

104106
Use the [Plausible UTM builder](https://plausible.io/utm-builder) to generate tagged links without doing it manually. Already have a link and want to check it for issues? Use the [UTM checker](https://plausible.io/utm-checker) to validate and clean it up. Once your campaigns are running, use the [ad cost calculator](https://plausible.io/ad-cost-calculator) to calculate your CPC, CPM and CPA from your campaign numbers. For naming conventions, session attribution rules and troubleshooting tips, see our [UTM tracking guide](https://plausible.io/blog/utm-tracking-tags).

‎sidebars.js‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ module.exports = {
1717
'change-domain-name',
1818
'general',
1919
'script-extensions',
20+
{
21+
type: 'category',
22+
label: 'Advanced tracking',
23+
items: [
24+
'custom-locations',
25+
'custom-query-params',
26+
'stop-tracking-utm-tags',
27+
],
28+
},
2029
'visibility',
2130
'shared-links',
2231
'embed-dashboard',

0 commit comments

Comments
 (0)