Installing the Mautic tracking script: what it does and when you need it
If you run a self-hosted Mautic instance and want anonymous page visits recorded on your websites, the tracking script mtc.js must be added to each site you want Mautic to follow. The script is the foundation for later visitor identification, dynamic content and focus items, so none of those features can work on a page that does not load it. Mautic is open source software licensed under GPL-3.0 with no paid edition of the software itself, so the script comes from your own Mautic instance and the work of placing and maintaining it sits with the team that operates that instance, not with a software vendor.
Before you copy anything, confirm the exact snippet behavior in your version. The tracking code is generated from the tracking settings in your instance, and the details of what it records, how it identifies a visitor and which domain it reports to can change between releases. Check the current Mautic documentation for your release line, and note which of your sites will load the script, which hostnames they use and whether any of them sit behind a custom domain or proxy, since those settings change what the snippet must reference. Your team should also decide who owns the snippet once it is live, because a change to the instance URL or domain later means updating every page that carries it.
Plan the rollout as an inventory task before it becomes a technical one. List every site and template that should report visits, including staging copies if you want test traffic kept separate, and record which content management system or hand-coded template holds the snippet. Any site that will later show dynamic content or focus items needs the script in place first, so treat this step as a prerequisite for those features. Ask your implementation partner or internal team to confirm how timezone and locale detection is handled in your version, because that data shapes the visit records you will rely on when you build segments and reports.
Which tracking script setup fits your websites
This is the simplest setup. Your team controls the page templates, so the tracking snippet from your Mautic tracking settings can be pasted into the HTML of every page you want recorded. The snippet is normally placed in the head or just before the closing body tag of a shared template, so a single change covers many pages. Developers or the web team usually make the edit, and it should go through your normal release process rather than a direct server edit.
- Shared template first: Add the snippet to a common layout or header include so new pages inherit it automatically.
- Copy from settings: Take the current code from the tracking settings in Mautic rather than retyping it, since the snippet references your Mautic base URL.
- Check page coverage: Confirm that landing pages, error pages and app pages you want tracked all load the shared template.
- Content security policy: Confirm that your CSP allows the script origin your Mautic instance serves from.
- Staging before production: Load a test page and confirm a visit appears in Mautic before releasing.
Before changing the template, confirm with the site owner which pages should and should not be tracked, and whether a consent banner must gate the script in your jurisdiction.
Many content management systems offer a Mautic plugin or extension that inserts the tracking code without editing templates. Look for it in the CMS plugin or extension marketplace and confirm that it is maintained for your CMS version and for the Mautic release line you run. Plugin details, names and compatibility change, so check the current listing and the Mautic documentation for specifics rather than relying on a memory of the plugin.
- Compatibility check: Confirm the plugin supports your CMS major version and your Mautic release line.
- Single settings point: Enter your Mautic base URL in the plugin settings, and confirm where the plugin stores it.
- Plugin versus theme edits: Confirm whether the plugin injects the script on every page or only where you enable it.
- Update path: Ask who receives plugin updates and who tests them against your Mautic version.
- Removal test: Confirm that disabling the plugin stops the script from loading.
Before installing, confirm with the CMS administrator who owns plugin changes, and whether the plugin has been reviewed under your change control process.
When your website is served from a custom domain, or when Mautic is reached through a different hostname than the one shown in default settings, the snippet can point to the wrong address. Visits then fail to record, or the script loads from a host that cannot set the tracking cookie. The fix is usually a change to the base URL the snippet uses, which should match the hostname your visitors actually reach Mautic on. Mautic's own configuration determines the base URL, so changes belong in the Mautic configuration rather than a hand edit of each page.
- Match the public hostname: Confirm the Mautic hostname used in the snippet matches the one your proxy and certificate serve.
- Check the tracking domain setting: Confirm which domain the tracking cookie is set for, and whether subdomains need to share it.
- Reverse proxy headers: Confirm the proxy passes the forwarded host and protocol headers Mautic expects.
- Secure connection: Confirm the snippet loads over HTTPS if your site does.
- Cache clearing: Clear application and CDN caches after the change so old snippets stop serving.
Before changing the domain, ask the server administrator to confirm the proxy and certificate configuration with the Mautic deployment owner.
Organizations with several websites, brands or country sites need a plan for where the snippet lives and how each site is identified. A single snippet on every site can work, but teams often need to know which site generated a visit, and whether the same contact should be recognized across sites. Decide this before rollout, because changing the approach later means revisiting every page. Consider how content owners on each site will request changes, and who approves them.
- Inventory the sites: List every domain, template system and editor who can change it.
- Shared or separate snippets: Decide whether all sites use one tracking setup or each site has its own configuration.
- Cross-domain behavior: Confirm whether visitors who move between sites should be treated as one visitor.
- Ownership map: Record who edits each site's snippet and who approves changes centrally.
- Regional rules: Confirm consent requirements for each market before enabling tracking on that site.
Before rollout, confirm the inventory and ownership map with the marketing, legal and web teams, and test each site individually rather than assuming one result applies to all.
Configuration options and when each fits
This table compares the four main ways to get the mtc.js snippet onto your sites: pasting it into a template, using a CMS plugin, pointing it at a custom domain, and relying on timezone and locale detection. Read each row for when the option fits, what it costs you in maintenance, and what to check before going live.
| Option | When it fits | Trade-off | What to verify |
|---|---|---|---|
| Copy the code from tracking settings into a site template | A small number of sites built on one template that your team controls directly | Every template change or new site needs the snippet pasted again, and edits can be lost in a redesign | The snippet appears on every public page once, not twice, and the page source shows your Mautic host |
| Use a CMS plugin | Sites on a CMS where a maintained Mautic or tracking plugin already fits your version of the CMS | Plugin compatibility must be checked on each CMS and plugin upgrade, and you depend on the plugin author's update cycle | Plugin version supports your CMS release, the plugin points at your Mautic host, and page visits appear in the contact timeline |
| Configure a custom domain so the snippet points at the right host | Mautic is reached on a subdomain or separate domain from the website being tracked | The snippet URL and the domain Mautic is configured to serve must match, so a domain change or move affects all tracked pages | Tracking requests reach the intended Mautic host over HTTPS, and the host setting matches the domain in your Mautic configuration |
| Rely on timezone and locale detection | Contacts in several regions where send times, dates or language-based content depend on the visitor's local settings | Detection is based on what the browser reports, so values can be missing or inaccurate for some visitors | Test a visit from a browser set to a different timezone and language, then confirm the values stored on the contact record |
| Enable detection and keep a fallback | Audiences that mix known and unknown locales, where a default must still apply when detection fails | A default value must be chosen and maintained, and visitors with no detected value will still receive it | Confirm the fallback behaves as expected for a visitor with no detected timezone or locale |
How to install mtc.js on a website
This sequence takes the tracking snippet from a verified Mautic instance to every site you own, with a staging check that confirms visits are recorded before anything goes live. Each step ends with a check so a broken snippet does not reach production sites.
Confirm the Mautic base URL and HTTPS access
Start by recording the exact base URL of your Mautic instance, including the protocol and any custom domain, and load it in a browser from outside your corporate network. Confirm the page loads over HTTPS with a valid certificate and that the Mautic login screen responds. Your web or platform team usually owns this check, because the tracking script is served from this address and browsers will block or ignore it if the domain or certificate is wrong. Done means the login page loads without certificate warnings and you have written down the base URL the snippet will reference.
Copy the snippet from tracking settings
Sign in as an administrator, open the tracking settings in Mautic, and copy the tracking script code shown there without editing the URL inside it. If your Mautic instance uses a custom domain or a proxy, check that the snippet points to that domain rather than an internal hostname, because the code is generated from the configured base URL. Store the snippet in your change record so the same version is used on every site. Done means you have a copy of the snippet whose script source matches the base URL you confirmed in the previous step.
Place the snippet in the site-wide template
Add the snippet to the shared template that every page of the website loads, usually the footer or the base layout, so it runs on all pages rather than only on the home page. If your site runs on a CMS with a tracking or header-injection setting, you can use that instead, but confirm with the CMS owner that the setting outputs the script on every page type. Keep a record of the template file and the change so it can be reverted. Done means the snippet appears once in the rendered HTML of a sample page, not duplicated across templates.
Deploy to a staging site first
Publish the change to a staging copy of the website and confirm the staging domain is allowed to send tracking data to your Mautic instance. Check the browser network panel on a staging page and confirm the mtc.js request returns successfully and no script errors appear in the console. If the staging site and production share a Mautic instance, label the test data so it can be removed later. Done means the script request succeeds on staging with no blocked or failed calls.
Load a test page and confirm the visit
Open a staging page in a private browser window, then open the same page in a second window while signed in to Mautic. Look for the anonymous visit in the visitors view or in the activity of the contact your test identifies, and confirm the page URL, time and referrer are recorded. Note that visits from an anonymous browser may appear as an unidentified visitor rather than a named contact, so check the visitors view first. Done means at least one test visit is recorded with the correct page URL.
Roll out to the remaining sites
Apply the same snippet and template change to each remaining site, one at a time, using the copy from your change record rather than retyping it. After each deployment, load one page per site and repeat the network and visit check from the previous steps. Sites that use a different template language or a separate CMS need their own placement check, so do not assume one change covers them all. Done means every site returns a recorded visit in Mautic and the change record lists each site and its verification date.
Prepare a rollback path
Before the production rollout, keep the previous template version and record how to remove the snippet, whether by reverting the template file or disabling the CMS setting. If the script causes errors or breaks page rendering, remove it, clear page caches and confirm the site loads normally again. Test the removal on staging so the rollback has been exercised, not just written down. Done means the team can remove the snippet from every site within a single change window and the removal has been tested on staging.
How a page visit reaches Mautic
The diagram starts in the visitor's browser, which loads the website page and then the mtc.js script from the Mautic instance. The script sends the page data back to Mautic, which records the visit against a contact or an anonymous record. Segment and campaign processing runs later on cron jobs, so it acts on recorded data rather than on the live request. Check that the script host is the Mautic domain you expect, and that cron runs are staggered and reaching the database.
Page visit flow from the visitor browser into Mautic, with cron-driven processing afterward.
How custom domains change the tracking snippet
The tracking snippet can differ from the one Mautic shows in its settings when the Mautic instance runs on a different hostname than the website that loads it. The script is served from the Mautic domain, so the page's visits are recorded against that host, and any mismatch between the hostname Mautic believes it lives on and the hostname visitors actually reach can produce a script URL that loads from the wrong place or fails silently. Decide early whether Mautic will sit on a subdomain such as a marketing or tracking hostname, and treat that choice as a configuration decision, not a cosmetic one.
Two settings deserve attention. The base URL that Mautic is configured with determines the absolute URLs it generates, including the script path, so it must match the public address visitors use. If Mautic sits behind a reverse proxy or load balancer, the proxy must pass the original host and protocol headers, and the Mautic trusted proxy configuration must accept them. Without this, Mautic can generate http links on an https site or point the snippet at an internal address. Confirm the exact configuration keys and header handling against the documentation for your Mautic version and your proxy, because these details have changed between release lines.
Retest after any change to the domain, the certificate or the proxy chain, not only after the first install. Load a test page on each site that embeds the script, check in the browser's network panel that the script and tracking requests succeed over HTTPS without mixed-content warnings, and confirm that a test visit appears on the expected contact or anonymous record. Repeat the check when a certificate renews onto a new chain or when a CDN or proxy rule changes. Record the test results so the next change has a baseline to compare against.
Security and privacy considerations for the tracking script
The tracking script runs in every visitor's browser and reports back to your Mautic host, so its source, transport, consent position and administrative access all need deliberate control. The cards below cover the decisions to settle before the snippet goes live and the checks to repeat after each release.
Control the script source
Every page that loads mtc.js runs code supplied by your Mautic instance, so anyone who can edit the snippet or the theme can change what visitors execute. Copy the snippet only from your own tracking settings, keep it under version control in your CMS or tag manager, and review any change to it as you would a change to application code. Confirm which host serves the script after a custom domain is set, because that host is the one visitors trust.
Serve everything over HTTPS
The tracking request carries page URLs, referrers and visitor identifiers, so it should never travel over plain HTTP. Put the Mautic host behind a valid TLS certificate, redirect HTTP to HTTPS, and confirm that the snippet on each site uses an HTTPS address. Mixed content warnings in the browser console are a signal that a page is still loading the script or endpoint insecurely.
Settle consent before the script loads
Whether the script can run before a visitor accepts cookies is a legal and policy question, not a configuration default. Agree with your compliance team which pages load the script, whether it waits for a consent signal from your banner, and how that decision is documented. Ask them to confirm the position for each region you serve, then test that the script stays inactive for visitors who decline.
Allow the Mautic domain in CSP
A content security policy that blocks unlisted script sources will stop mtc.js from loading, and the failure is often silent for marketing staff. Add the Mautic host to the relevant script-src and connect-src directives, and keep the list as narrow as possible. Review the policy again whenever the custom domain or CDN changes, since the snippet's source host changes with it.
Limit who can change tracking
Mautic manages users with basic authentication, and the people who can edit tracking settings can change what every visitor's browser sends. Restrict tracking configuration to a small set of administrators through user roles, and review that list when people change jobs. Confirm with your identity team whether a SAML identity provider will sign these users in, since the provider must send email, first name and last name attributes.
Mautic authentication docsKeep the release line supported
The tracking endpoint is part of the Mautic application, so a security fix to the application patches the script path too. Confirm which release line your instance runs, and plan upgrades before its security support ends. Mautic 5.2 (Capella) security support ends on 30 June 2026, and Mautic 6.0 (Tabit) on 30 September 2026, so an instance on either line needs a dated upgrade plan.
Mautic releasesQuestions teams ask before installing the tracking script
How much effort does a single-site tracking script install take?
For one site where you already control the template or can add a header snippet, the code change itself is small. Effort rises with the number of sites, how much access you have to each CMS, whether changes go through a release process, and whether marketing, legal or privacy staff must review what the script records. Ask any provider to split the quote into the Mautic configuration, the per-site code changes, testing on each site and the review cycle, so you can see which part your team would absorb.
Can our team install the Mautic tracking script without outside help?
Often yes, if one person can open the tracking settings in Mautic, copy the snippet, and place it in each site's global template or tag manager. The harder cases are sites built on several CMS platforms, sites with strict change control, and setups where the Mautic domain differs from the site domain. Check that your Mautic instance is installed and maintained properly first, since the tracking script depends on it being reachable and stable. Outside help is most useful for planning the placement across sites and verifying the results.
What access and inputs does a tracking script project need from us?
Plan for four inputs before work starts:
- Administrator access to the Mautic instance, so the tracking settings can be read and tested.
- Edit or deployment access to each website, or to the tag manager that loads the script.
- A staging or test copy of at least one site where changes can be checked before they reach visitors.
- A named owner on your side who approves changes and decides which pages and domains are in scope.
Without a named owner, placement decisions tend to stall between marketing and engineering.
What would a partner deliver for a tracking script installation?
A written scope should list the sites covered, the Mautic tracking settings used, the exact placement of the snippet on each site or in each tag manager, and the test evidence. Good deliverables include a short runbook for adding the script to new pages, a record of which timezone and locale detection options were set, and a check that page visits appear as expected in Mautic. Ask whether the work includes changes to Mautic itself, retesting after CMS updates, and handover, since those affect the cost and what your team inherits.
Does the Mautic tracking script slow down our website?
The script is an extra request that loads on each page, so it adds some work to the browser and to the network. The impact depends on where the script is loaded, whether it is deferred, how fast your Mautic server responds, and how many other third-party scripts already run on the page. Measure page load before and after on a staging copy using your normal performance tools. If you add other tracking tools, such as tag managers or analytics pixels, test the combined effect rather than the script alone.
What changes if our Mautic domain changes after the script is installed?
The tracking snippet points to your Mautic domain, so a domain change means the code on every site must be updated and redeployed. Mautic also needs its own URL settings to match the new domain, and custom domains can change the snippet Mautic generates. Plan the change as a coordinated release: update Mautic, update the snippet on each site, test on staging, then deploy. Keep the old domain reachable for a period so visitors with cached pages still send data. Confirm the exact steps for your Mautic version in the vendor's documentation.
Does the tracking script need consent review before it goes live?
Usually yes, because the script records visits that can be linked to people. Your privacy or legal team should confirm what is recorded, how visitors are told about it, and how consent settings in your site and in Mautic are applied. The review adds time to the project and is often the longest step for regulated organizations. Ask any provider to include a list of recorded data points and the configuration used, so your reviewers have something concrete to assess.
Do we need a staging environment to install the script safely?
A staging environment is strongly recommended. It lets you confirm that the snippet loads, that visits are recorded under the right Mautic domain, and that no page breaks when the script is added. Without staging, the first test happens on live visitors. If you cannot maintain a full copy of your sites, use a single representative template and a test Mautic environment at minimum.
How DeployOpen scopes and delivers tracking script installs
DeployOpen handles the tracking script install as part of a fixed-scope engagement, with the scope agreed in writing before any change is made to a site. The written scope lists every website that will receive mtc.js, the CMS platform or static setup behind each one, any custom domains that alter the snippet, the Mautic environment that receives the data, and who on your side approves production changes. It also records the tracking settings to be applied, including timezone and locale detection, and which pages are excluded. Because DeployOpen implements self-hosted Mautic inside your own infrastructure, the scope names the hosts, DNS records and certificates involved so that nothing depends on a vendor-hosted endpoint you have not reviewed.
Delivery follows a sequence that you can check at each step. First, the snippet and any CMS plugin are installed on a staging copy of each site, and the team confirms that visits appear as expected in Mautic for a logged-out browser, a logged-in contact and a custom domain. Second, the production rollout is made in a planned change window, with the same checks repeated on live pages and the Mautic tracking settings reviewed against the agreed scope. Third, handover notes record the exact snippet version, where it lives in each CMS, the custom domain configuration, a rollback step and the owner for future changes. Ask any provider for these artifacts in the quote, and confirm which of them are included in the fixed scope and which are billed separately.
Ongoing support is available as a retainer for work that follows the install, such as updating the snippet after a Mautic upgrade, adding sites or checking tracking after a CMS change. Confirm with DeployOpen during scoping which items fall inside the initial fixed scope and which fall under a retainer, so that your team knows who owns each change once the project closes.

