Add CLItrail to Wix
Where the CLItrail tag goes in Wix, in its own idiom, with the consent, CSP and client-side routing details and how to check it works.
#Where the tag goes
Edit Settings → Custom Code → Add Custom Code (Head, All pages, load once). Put the tag on every page that shows your install command; site-wide is best, after your existing analytics tags.
<script defer src="https://YOUR_SERVICE/browser.js" data-website="YOUR_WEBSITE_ID"></script>
#Only after consent
Wix treats custom code as Essential by default, and Essential code loads before consent. Categorize the tag as Analytic (Marketing when installs go to ad platforms) so Wix's cookie banner handles it as non-essential. With your own consent manager instead, add the loader below in place of the tag and call startClitrail() from its accept callback.
<script defer src="https://YOUR_SERVICE/browser.js" data-website="YOUR_WEBSITE_ID"></script>
With your own consent manager
<script>
// Loads CLItrail only after the visitor agrees. Call startClitrail() from your
// consent manager's "accepted" callback; nothing is fetched or stored before that.
window.startClitrail = () => {
if (document.getElementById('clitrail')) return;
const tag = document.createElement('script');
tag.id = 'clitrail';
tag.src = 'https://YOUR_SERVICE/browser.js';
tag.dataset.website = 'YOUR_WEBSITE_ID';
document.head.append(tag);
};
</script>
#Client-side routing
Wix can load custom code once per visit or on each new page. Keep the tag on once. To also record your install page when visitors reach it inside the site, add this as a second snippet for that page only, loaded on each new page:
<script>
(() => {
// The tag records the page the browser loaded; this records the page when it is opened in-site.
const sdk = window.InstallAttribution;
const loaded = new URL(performance.getEntriesByType('navigation')[0]?.name ?? location.href).pathname;
if (sdk?.ready && location.pathname !== loaded) sdk.ready = sdk.init({ service: 'https://YOUR_SERVICE', project: 'YOUR_WEBSITE_ID' });
})();
</script>
#Content Security Policy
Wix serves the pages. If you put a Content-Security-Policy in front of them (for example through your own proxy), add https://YOUR_SERVICE to script-src and connect-src, and blob: to worker-src (only Safari before 26 needs that one).
script-src 'self' https://YOUR_SERVICE;
connect-src 'self' https://YOUR_SERVICE;
worker-src 'self' blob:;
#Verify it works
- Publish the site.
- Open a page with the tag in Chrome or Firefox (accept analytics first if you gate CLItrail on consent), open the developer console and run
await InstallAttribution.ready. It resolves to{ ok: true, urlId, hasAnalyticsContext, expiresAt }. - In the CLItrail dashboard, open Visits & identities: the visit is listed.
- Anything else names the cause:
disabled(no consent yet, ordata-enabled="false"),opfs_unavailable(the page is not served over https or from localhost),Error(the service refused the visit: add the page's origin, including a development origin such ashttp://localhost:3000, under Settings → Additional domains). IfInstallAttributionis undefined, the tag did not load: check the Network tab and your Content-Security-Policy.
Then run your installer on the same computer and check Install events, or run the hook with --doctor.
#If a visit is not recorded
Start the SDK yourself: this adds the tag without data-website and calls InstallAttribution.init once it loads.
Manual start
<script>
(() => {
if (window.InstallAttribution) return;
const tag = document.createElement('script');
tag.src = 'https://YOUR_SERVICE/browser.js';
tag.onload = () => {
const sdk = window.InstallAttribution;
sdk.ready = sdk.init({ service: 'https://YOUR_SERVICE', project: 'YOUR_WEBSITE_ID' });
};
document.head.append(tag);
})();
</script>
#Notes
Custom code runs only on a published site with a connected domain.
Wix documentation: support.wix.com/en/article/embedding-custom-code-to-your-site
Using other install paths or destinations? The setup generator puts this snippet together with your hooks and destination checklist.