|
1 | 1 | --- |
2 | 2 | displayed_sidebar: someSidebar |
3 | | -title: Exclude yourself via localStorage |
4 | | -sidebar_label: Exclude yourself via localStorage |
5 | | -description: "Exclude your own visits from Plausible tracking by setting a localStorage flag in your browser's developer console. No IP address or server changes needed." |
| 3 | +title: Let visitors opt out of being counted |
| 4 | +sidebar_label: Visitor opt-out |
| 5 | +description: "Give your visitors a way to opt out of Plausible Analytics with a ready-made opt-out page you link from your privacy policy. No cookies or server changes needed." |
6 | 6 | --- |
7 | 7 |
|
8 | 8 | import useBaseUrl from '@docusaurus/useBaseUrl'; |
9 | 9 |
|
10 | | -:::tip You can exclude internal traffic by IP address too |
11 | | -This is the easiest way to exclude your own visits from being traffic. [See how here](excluding.md) |
12 | | -::: |
| 10 | +Plausible doesn't use cookies or store personal data, so there's nothing for your visitors to consent to. Some privacy guidelines still expect visitors to have a way to object to analytics. An opt-out page on your site gives them one. Link to it from your privacy policy. |
13 | 11 |
|
14 | | -To prevent counting your visits, you can set a special `localStorage` flag in the browser. Here's how. |
| 12 | +## How the opt-out works |
15 | 13 |
|
16 | | -## To exclude your visits from being counted |
| 14 | +The opt-out page sets a `plausible_ignore` flag in the visitor's browser `localStorage`. While the flag is set, the Plausible script doesn't send any pageviews or events from that browser. |
17 | 15 |
|
18 | | -Visit the website you'd like to exclude your visits from and open the developer tools in your browser. Right-click anywhere on your page and click **Inspect** (the wording may vary depending on your web browser) to open the developer tools. Alternatively, press `F12` on Firefox or Chrome or `Option+Command+i` on Safari. Then click the "Console" tab. |
| 16 | +* The choice stays in place until the visitor turns counting back on or clears their browser data |
| 17 | +* It applies per browser and per domain. A visitor who uses several browsers or devices needs to opt out on each of them |
| 18 | +* The opt-out page must be on the same domain as the site it opts out of. If you track several subdomains, each needs its own opt-out page |
| 19 | +* The opt-out takes full effect from the next page load. The opt-out page itself was already counted when it loaded, so time spent on that page may still be recorded |
19 | 20 |
|
20 | | -In Firefox, it looks like this: |
| 21 | +## Add an opt-out page to your site |
21 | 22 |
|
22 | | -<img alt="Browser web console" src={useBaseUrl('img/browser-console.png')} /> |
| 23 | +We have created a ready-made opt-out page you can use freely on your site. Visitors click one button to opt out, and the same button turns counting back on. There are two versions: one with a CSS stylesheet if you want to use our style, and one without any styling if you'd like to bring your own. |
23 | 24 |
|
24 | | -Then paste the following command and hit enter: |
| 25 | +<img alt="Opt-out page screenshot" src={useBaseUrl('img/exclusion-page-example.png')} /> |
25 | 26 |
|
26 | | -```html |
27 | | -localStorage.plausible_ignore=true |
28 | | -``` |
29 | | - |
30 | | -It will look something like this when you paste the command: |
31 | | - |
32 | | -<img alt="Browser web console enter the command" src={useBaseUrl('img/exclude-yourself.png')} /> |
| 27 | +For the styled version, download the <a target="_blank" download="index.html" href="/docs/exclusion-examples/exclude.html">HTML file</a> and the <a target="_blank" download="plausible-exclusion.css" href="/docs/exclusion-examples/plausible-exclusion.css">CSS file</a> and make both available together on your website. If you'd prefer a light theme, delete the `dark` class from line 1 of the HTML file. |
33 | 28 |
|
34 | | -And you will get this message when you hit enter: |
| 29 | +For the unstyled version, download the <a target="_blank" download="index.html" href="/docs/exclusion-examples/exclude-bare.html">HTML file</a> and make it available on your website with any CSS you choose to add. |
35 | 30 |
|
36 | | -<img alt="Browser web console true" src={useBaseUrl('img/exclude-yourself-true.png')} /> |
| 31 | +Then add a link to the page in your privacy policy, for instance: "You can opt out of being counted in our analytics on [this page]." |
37 | 32 |
|
38 | | -Note that you have to follow this process for every domain and subdomain you'd like to exclude your visits from. If you use multiple browsers, you also need to follow the same process on every browser you'd like not to be counted. |
| 33 | +## Check that the opt-out works |
39 | 34 |
|
40 | | -## Return to your site to ensure the exclusion works |
41 | | - |
42 | | -There are two ways you can check to ensure that you have excluded your visits: |
43 | | - |
44 | | -* 1: Reload your site multiple times and make sure that the total page views number in your Plausible dashboard does not increase. This isn't very reliable if there are other people visiting your site at the same time. |
45 | | - |
46 | | -* 2: Reload your site and open the browser console again. If you have excluded yourself, you should see a message saying "Ignoring Event: localStorage flag". You may need to ensure the "Warnings" filter (in the top right in Firefox and top-center under a dropdown in Chrome) is enabled before this message is visible. |
| 35 | +Opt out on the page, then visit another page on your site and open the developer tools in your browser (right-click and choose **Inspect**, or press `F12` on Firefox or Chrome or `Option+Command+i` on Safari). In the **Console** tab you should see the message "Ignoring Event: localStorage flag". You may need to enable the "Warnings" filter to see it. |
47 | 36 |
|
48 | 37 | <img alt="Browser web console check" src={useBaseUrl('img/check-the-exclusion.png')} /> |
49 | 38 |
|
50 | | -## To re-enable counting of your visits |
| 39 | +## Excluding your own visits |
51 | 40 |
|
52 | | -To re-enable counting of your visits, you need to visit the website you'd like to enable the counting of your visits for. Open the web console in your browser and then click the "Console" tab. |
| 41 | +To keep your own visits or your team's out of your stats, [block your IP addresses](excluding.md) in your site settings. That works across all your browsers and devices at once. |
53 | 42 |
|
54 | | -Then paste the following command and hit enter: |
| 43 | +If your IP address changes often or you use a VPN, you can set the same flag yourself instead. Open the **Console** tab in your browser's developer tools on your site, then paste this command and hit enter: |
55 | 44 |
|
56 | 45 | ```html |
57 | | -delete localStorage.plausible_ignore |
| 46 | +localStorage.plausible_ignore=true |
58 | 47 | ``` |
59 | 48 |
|
60 | | -## Allow anyone on your site to exclude themselves |
| 49 | +Do this for every domain, subdomain and browser you want to exclude. To be counted again, run: |
61 | 50 |
|
62 | | -To allow anyone on your site (usually beta testers or internal users) to exclude themselves from analytics, you could have them follow the steps above on every device, or you could provide a page on your website to do this automatically. |
63 | | - |
64 | | -We have created a downloadable version of such a page for you to use freely on your site. There are two versions of this example, one with a CSS stylesheet included if you want to use our style, and another without any styling if you'd like to bring your own. |
65 | | - |
66 | | -:::note |
67 | | -With this method, similar to above, the page needs to be visited and the exclusion enabled per domain and per browser, for every user. The page must also be made available on the same domain you wish to exclude analytics for. The exclusion takes full effect from the next page load: the page where it's turned on was already counted when it loaded, so time spent on that page may still be recorded. |
68 | | -::: |
69 | | - |
70 | | -### Preview |
71 | | - |
72 | | -<img alt="Exclusion page screenshot" src={useBaseUrl('img/exclusion-page-example.png')} /> |
73 | | - |
74 | | -### Download and Deploy |
75 | | - |
76 | | -For the styled version of this page, you'll need to download a <a target="_blank" download="index.html" href="/docs/exclusion-examples/exclude.html">HTML file</a> and a <a target="_blank" download="plausible-exclusion.css" href="/docs/exclusion-examples/plausible-exclusion.css">CSS file</a> and make both available together on your website. |
77 | | - |
78 | | -(If you'd prefer a light-theme for this page, you can delete the `dark` class from line 1 of the above HTML file) |
| 51 | +```html |
| 52 | +delete localStorage.plausible_ignore |
| 53 | +``` |
79 | 54 |
|
80 | | -For the unstyled/bare version, you'll just need to download a <a target="_blank" download="index.html" href="/docs/exclusion-examples/exclude-bare.html">HTML file</a>, and make it available on your website with any CSS you choose to add. |
| 55 | +You can also use the opt-out page above instead of the console. |
0 commit comments