Onboard a client
Add a new client through the API, get its publishable key, and install the Mythic tracking pixel on the client's site — end to end.
Overview
When you take on a new client, three things happen: you create the client (the API mints its keys), you fetch the loader snippet, and you install the pixel on the client's site. This page walks the whole flow with copy-paste requests.
https://mythic-analytics.gulp.workers.dev
Client creation and loader retrieval run on the provisioning API (/api/v1) with your server-side API key. The publishable_key you get back is the only credential that goes on the client's website — it's browser-safe.
Steps
Create the client
POST /api/v1/clients. Only id and name are required — the API auto-generates the client's publishable_key (pk_) and secret_key (sk_).
curl -X POST "https://mythic-analytics.gulp.workers.dev/api/v1/clients" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"id": "acme-retail",
"name": "Acme Retail",
"domain": "acme-retail.com"
}'
{
"success": true,
"data": {
"id": "acme-retail",
"name": "Acme Retail",
"status": true,
"publishable_key": "pk_example000000000000000000000000",
"secret_key": "sk_example000000000000000000000000",
"domain": "acme-retail.com",
"created_at": "2026-07-13T16:13:43.509Z",
"updated_at": "2026-07-13T16:13:43.509Z"
}
}
Save the publishable_key — it's what goes on the client's site. The secret_key is a read-only server-side credential you can hand to the client for their own dashboards. Both are also retrievable later from the client record.
Get the loader snippet
GET /api/v1/clients/{id}/loader returns a ready-to-paste <script> snippet, a hosted builder URL, and an iframe embed for that URL. No need to assemble anything by hand.
curl "https://mythic-analytics.gulp.workers.dev/api/v1/clients/acme-retail/loader" \
-H "Authorization: Bearer YOUR_API_KEY"
{
"success": true,
"data": {
"publishable_key": "pk_example000000000000000000000000",
"embed_url": "https://api.adberserk.com/embed/loader/pk_example000000000000000000000000",
"iframe_snippet": "<iframe src="https://api.adberserk.com/embed/loader/pk_example000000000000000000000000" width="100%" height="800" frameborder="0"></iframe>",
"script_snippet": "<script>!function(){var u="https://api.adberserk.com/decide?key=pk_example000000000000000000000000&v=2",r=fetch(u,{cache:"default"});r.catch(function(){});window.__mythicCfgPrefetch={url:u,response:r};var l=document.createElement("link");l.rel="modulepreload";l.href="https://api.adberserk.com/cdn/core/mythic.mjs";(document.head||document.body).appendChild(l);var b=window.__mythicErr=window.__mythicErr||{q:[],sink:null};if(!b.on){b.on=1;var p=function(x){b.sink?b.sink(x):b.q.length<50&&b.q.push(x)};window.addEventListener("error",function(v){p({k:0,m:v.message,f:v.filename,l:v.lineno,c:v.colno,e:v.error})},!0);window.addEventListener("unhandledrejection",function(v){p({k:1,r:v.reason})},!0)}var e=[];window.mythic={init:function(t,n){return e.push(["init",t,n]),window.mythic},q:e};["capture","pageview","identify","alias","reset","opt_in","opt_out","flush","debug","getDistinctId","getSessionId","getDeviceId","isBot","getConfig","set","set_once","unset","get_property","get_super_properties","clear_super_properties","getPageContext","getExperimentAssignments","refreshConfig","grantConsent","revokeConsent"].forEach(function(t){window.mythic[t]=function(){return e.push([t].concat(Array.prototype.slice.call(arguments))),window.mythic}});var t=document.createElement("script");t.type="text/javascript";t.async=!0;t.src="https://api.adberserk.com/cdn/m.js";(document.head||document.body).appendChild(t)}();
mythic.init("pk_example000000000000000000000000", {api_host: "https://api.adberserk.com"});</script>"
}
}
A self-contained <script> tag. It installs the early error listeners, stubs window.mythic (or the client's global_name), loads the CDN loader asynchronously, and calls init with the client's key and API host. Queues any calls made before the SDK finishes loading. This is the one to give the client.
A hosted, no-auth snippet builder for this key. Open it to preview and customize the install, or hand the link to a non-technical client.
The embed_url wrapped in an iframe — drop it into your own agency portal so clients can copy their snippet without leaving your app.
Install the pixel on the client's site
Paste the script_snippet into the client's site, high in <head>. That's it — page views auto-capture immediately.
<script>!function(){/* ...from script_snippet... */}();
mythic.init("pk_example000000000000000000000000", {api_host: "https://api.adberserk.com"});</script>
Paste it as high in <head> as possible, above any tag manager — the snippet installs the error listeners synchronously, so anything thrown before it runs isn't captured.
Verify install: load the client's site and confirm events arrive via the Data API event summary, or watch the network tab for a request to /e?key=pk_....
Hand it off without touching code
If the client installs their own tag, skip the copy-paste entirely — send them the embed_url from step 2. It's a hosted page that renders their snippet with a copy button and a live config preview, or embed it in your portal with the iframe_snippet.