Skip to content

docs: Document MauticJS.withdrawTrackingConsent() and /mtc/withdraw (7.3) - #988

Draft
promptless-for-oss wants to merge 4 commits into
mautic:7.3from
Promptless:promptless/pr-18400-withdraw-tracking-consent
Draft

promptless-for-oss wants to merge 4 commits into
mautic:7.3from
Promptless:promptless/pr-18400-withdraw-tracking-consent

Conversation

@promptless-for-oss

@promptless-for-oss promptless-for-oss commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Open in Promptless

Description

Documents the tracking consent withdrawal API added in mautic/mautic#18400 (open, targets 7.x).

docs/mauticjs_api/tracking_script.rst now covers:

  • MauticJS.withdrawTrackingConsent(callback) under MauticJS API functions: it's in the TRACKING scope only, what it does in the browser, and what the callback receives. The method sends the device IDs from the cookie and local storage, removes them from the website only after Mautic responds with {"success": 1}, and can be called again after false.
  • The POST /mtc/withdraw endpoint for consent managers that run where the tracking script isn't loaded: where Mautic takes the device IDs from (the parameter accepts two, separated by commas, and Mautic ignores any after the first two), which devices and cookies it clears, the response, including {"success": 0} when a User has logged in to Mautic in that browser, and that it accepts only POST.
  • The MauticJS.trackingEnabled global, which the method sets back to false.
  • Cross-domain use: when the website is on another domain and Restrict Domains is on, its domain must be in Valid Domains, as for /mtc/event, or the browser blocks the request and the callback receives false (review, reviewer request).
  • Shared device IDs: Mautic keeps one device per Contact for each device type, brand, model, and operating system, so two browsers on the same device can share a device ID, and withdrawing in one also stops the other's ID from identifying the Contact.

The companion user-documentation suggestion covers the same change for site owners. Please merge this after mautic/mautic#18400 merges.

The source PR author confirmed the confirmation-first ID removal, the CORS requirement, and the shared-device limit in the source PR review replies and the PR description, so this revision needs no content change for them.

Validation 2 passed 1 not run
  • ✓ Vale (collection config): 0 new findings; 3 existing errors elsewhere on the page are unchanged
  • ✓ rstcheck: no new issues (only the existing custom :xref: role is reported)
  • – Sphinx HTML build: not run, because docs/requirements.txt pins packages that need Python 3.13.5+, which this environment can't install

Linked issue

Related to mautic/mautic#18391

Trigger Events

Comment thread docs/mauticjs_api/tracking_script.rst Resolved
@promptless-for-oss

promptless-for-oss commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor Author

The build check failure on commit 6128de2 doesn't come from this PR. It has the same cause as the earlier failures on e8241ed, b829044, and a50b8bc. The "Check links" step found only two broken links, both on line 48 of docs/index.rst, which this PR doesn't change:

  • https://community.mautic.org/processes/roadmap
  • https://community.mautic.org/assemblies/product-team

Both returned a 500 server error during the run, and both still returned 500 when Promptless checked them afterward. Every link on docs/mauticjs_api/tracking_script.rst, the only page this PR changes, passed the check. This run used a newer Python (3.15.2), but that isn't the cause: dependencies installed and the docs built before the link check failed. Other docs PRs on this repository fail the same way.

The check will keep failing until community.mautic.org serves those pages again, or until those links on docs/index.rst are changed or added to linkcheck_ignore in the base branch. After that, re-run the build check and it should pass. Promptless made no changes to this PR.

@vukovicpredrag

Copy link
Copy Markdown

@promptless-for-oss Could you add one sentence? When the website is on a different domain than Mautic and Restrict Domains is on in the CORS settings, the website's domain has to be in Valid Domains. Otherwise the browser blocks the request and the callback gets false. It's the same rule as for /mtc/event.

@promptless-for-oss

Copy link
Copy Markdown
Contributor Author

In reply to this discussion

Thanks, I'm adding the CORS sentence (website's domain in Valid Domains when Restrict Domains is on) to this page now. I'll reply here once it's in.

@promptless-for-oss

Copy link
Copy Markdown
Contributor Author

In reply to this discussion

Thanks, I've added it. The page now says that when the website is on another domain and Restrict Domains is Yes, the website's domain has to be in Valid Domains, as for /mtc/event. Otherwise the browser blocks the request and the callback receives false. I checked this against the code: Mautic only sends the CORS headers in its preflight response when the origin is allowed.

I also fixed a second point in this page and in the user docs (mautic/user-documentation#1247). Two browsers on the same device can share one device ID, so withdrawing consent in one browser also forgets the other. Both pages describe the code as it is now. If mautic/mautic#18400 changes how this works, that sentence needs updating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants