matomo-org / matomo-org/matomo

setSiteId = null - for deactivate tracking

Open
#20,522 3 comments 0 reactions 0 assignees View on GitHub
Enhancement
Dominant language
PHP
Stars
21.9k
Forks
2.9k
Avg merge
3d 3h
Merged PRs (30d)
139

Description

4.14.1

For maintenance and other situation it is necessary to deactivate matomo temporarilly. Other situations are like my case: The matomo tracking script is included via PHP `include` and before a `config` file per website is included. In this`config` file is the matomo `siteID` setted as a PHP variable and this is placed in the matomo tracking code via PHP ``. Few pages, that are similar in all websites (like imprint, about, etc.) are generated like a global CMS and included the CMS websites. In this pages are also the same matomo tracking script and the siteID from the same `config` is included. There is also only 1 `config` per website. But for first situation, there is free space between the two PHP `include` (config, matmo script). This free space is suitable to put a new value in the PHP `$siteID` variable for the matmo tracking code. But current, there is no way to use siteID `0`, because also with this is data send to the matomo installation and gives a "Tracking failure". For second situation it is needed to set a special siteID in the `config` to deactivate the tracking on the complete website, ... consider, the few similar pages can not deactivate over an another way.

I had tested a siteID `null`, but is the same problem as siteID `0` . But a siteID `null` was appropriate to use it for deactivate the tracking and don't send data to the matomo installation.
```
if (siteID === null) {
// deactivate tracking
}
// or in opposite
if (siteID !== null) {
// activate tracking
}
```
Or make it simpler and deactivate also by siteID `0`.
```
if (siteID) {
// deactivate tracking
}
// or in opposite
if (!siteID) {
// activate tracking
}
```

background:
```
Boolean(null) // false
Boolean(0) // false
Boolean(!null) // true
Boolean(!0) // true
```

Contributor guide

Open the contributing guide

Research direction

No repository file, entry point, or test is named. Start by tracing how the tracking code consumes the siteID and how PHP-generated pages pass it into that code; define the deactivation behavior and add coverage for null, zero, and normal site IDs before verifying that no tracking request is sent when deactivated.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, php
Domain
analytics
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.