API & MCP server
Use TrackingCoder from code or from an AI assistant: keys, endpoints, the six MCP tools.
Everything the app does can be driven from your own code or from an AI assistant. The TrackingCoder MCP server is a website tracking MCP for Claude Code, Claude Desktop, Cursor, VS Code and Codex; the REST API is the same capability for your own code. Both use the same API key, which acts as your account: the same credit pools, the same Pro workspace, the same Google connection, the same limits, and the same charges when you generate. The MCP page has the overview and a video tour.
ℹ A TC Pro feature
What you can do with it, and what you cannot
- Read: the catalog of events, channels and prices; your credit balance; the Google Tag Manager accounts, containers and workspaces your connected Google account can edit; your live monitoring data (counts per event and channel, conversion rates, traffic sources, goals, score).
- Diagnose: scan a site, detect its tracking, check its consent behaviour. These cost you nothing and are rate limited.
- Act: generate tracking for one event on one channel (the only action that spends credits, exactly like the wizard); push a generation into a GTM workspace as unpublished changes, exactly like the app's one-click button; export a branded client report or a consent report as a 24-hour link. Generation and pushes each need an explicit confirmation.
- Not through the API or MCP: publishing a GTM version, buying credits or changing billing, creating or revoking keys, team and workspace changes, and the IDs stored in your vault. Those stay in the app and in GTM, where you can see what you are doing.
API keys
Create keys at Account, MCP & API Keys. A key looks like tc_live_…, is shown once, and can be revoked at any time. Send the whole key, prefix included, as a Bearer token (the snippets below write it as YOUR_API_KEY):
Authorization: Bearer tc_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- Up to 10 active keys per account. Name them by where they are used, so you can revoke one without touching the rest.
- A key resolves to the same user and workspace as your browser session: if you are in a Pro workspace with an active subscription, generation draws on the workspace pool; otherwise on your personal pool.
- Keys cannot create or revoke other keys. That stays in the dashboard.
Endpoints
Base URL https://trackingcoder.com. JSON in, JSON out. Errors come back as { "error": "..." } with a 4xx or 5xx status.
GET /api/scenarios
Public catalog, no key needed: every event type with its credit cost and free-plan eligibility, every channel with the ID it needs, the advanced parameters, output formats and pricing rules. Cached for an hour.
POST /api/scan
Scans a public website: CMS, builder, forms, e-commerce platform, installed analytics and pixels, page types. Returns the profile and a scanId (valid 24 hours) for generation. Works without a key too, with tighter limits.
POST /api/scan
{ "url": "https://example.com" }
200 { "scanId": "…", "profile": { "cms": "WordPress", "builder": "Elementor", "formsDetected": ["Contact Form 7"], "hasGA4": true, … }, "scanMethod": "browserless" }POST /api/generate
Generates the tracking for one event on one channel. Spends credits: the scenario's cost (1 for most events), plus 1 per advanced parameter, plus 1 for Consent Mode v2. Free credits cover the basic events on GA4. Identical requests within two minutes return the first result without charging again.
POST /api/generate
{
"scanId": "…",
"scenarioName": "form_submission",
"channel": "ga4",
"channelId": "G-XXXXXXXXXX",
"outputFormat": "gtm_container",
"discoveryAnswers": { "formPlugin": "Contact Form 7", "pageUrl": "/contact" },
"advancedParams": ["prev_page"],
"requireConsent": true
}
200 { "gtmContainerJson": "…", "gtmCode": "…", "code": "…", "metadata": { "eventName": "form_submission", … },
"creditsCharged": 2, "freeCreditsUsed": 0, "newBalance": { "credits": 18, "freeCredits": 5 } }
402 { "error": "Not enough credits…" } 403 { "error": "…not included in the Free plan…", "code": "free_tier_restricted" }scenarioNameis the scenario'skeyfrom the catalog (for exampleform_submission,button_click,purchase); the MCP tools also accept the display name and map it.channelisga4,meta,gads,linkedinormsads;channelIdSecondarycarries the Google Ads conversion label.outputFormat:gtm_container(import JSON, default for the API),gtm_html(a Custom HTML snippet) ordirect(a script for the page).advancedParams(GA4 only; ignored and not charged on ad channels) andrequireConsent(every channel, +1 credit) work exactly as in the wizard.discoveryAnswersare the wizard's questions, optional:elementText,pageUrl,pageSection,formPlugin,formPurpose,afterSubmit,pageScope,videoScope,paymentProvider,paymentFlow.
GET /api/credits
The balance of the active pool, plus both pools, and when free credits renew.
POST /api/tools/consent-check and POST /api/tools/track-detect
The free tools, as JSON: { "url": "…" }. The consent check returns the verdict, the six checks and the evidence; the tracking detector returns the pixels found and the core channels missing. Rate limited per caller; a key does not raise those limits.
Credits and billing
- Credits are the only currency. A generation through the API or MCP draws on the same pool as the wizard: your Pro workspace pool (10 credits included every month, plus any packs), or your personal pool when you are not in a workspace.
- When the pool is empty the call fails with HTTP 402 and a message pointing to Buy credits. Nothing can be bought through the API or MCP; you top up in the app.
- Identical requests within two minutes return the first result without a second charge, so a retry after a lost connection is safe.
- Through MCP, the assistant must pass
confirm: trueon every generation, and its instructions tell it to state the scenario, channel, ID and cost and wait for your approval first.
Rate limits
- Scans: 5 a minute, 30 an hour, 100 a day with a key (anonymous: 3, 10, 20).
- Consent checks: 4 a minute, 15 an hour, 40 a day. Tracking detection: 12 a minute, 60 an hour.
- MCP: 60 calls a minute per key, and per key per day at most 100 scans, 40 consent checks, 50 generations, 30 GTM pushes and 20 report exports.
Limits answer with HTTP 429 and a Retry-After header. A paused subscription answers 403 with pro_required.
The TC MCP server
The same capabilities as tools for AI assistants, through the Model Context Protocol. The server runs at https://trackingcoder.com/api/mcpover Streamable HTTP (stateless JSON), authenticated with your API key as a Bearer token.
list_scenarios: the catalog.scan_site: scan a URL, get a scanId.describe_scenario: the wizard's questions for one event (which form or page, which button text, what happens after submit, which widget or payment flow), with their options, which are required, and hints from the scan. The assistant asks you those, then passes the answers asdiscoveryAnswers. A generation missing a required answer is refused without charge and lists what to ask. PasschannelIdas"vault"to use the ID saved for the site in your ID Vault, so nobody has to look it up; the assistant cannot list the vault, only ask for the one saved for a site.generate_tracking: generate one event for one channel. Spends credits; requiresconfirm: true, which the assistant is told to set only after your approval. Returns agenerationIdfor the push.list_gtm_workspaces: the accounts, containers and workspaces your connected Google account can edit.push_to_gtm: place a generation in a workspace (by path, or by container id such as GTM-ABC1234 plus a workspace name) as unpublished changes. Requiresconfirm: true. Large containers may hand back a cursor to continue with.get_monitoring: the workspace overview, or one monitored site's counts per event and channel, conversion rates, traffic sources, daily volume, goals and score for a range.export_report: the branded client report for a monitored site, or the consent report for any URL, as a link valid 24 hours (PDF by default, printable HTML otherwise).get_credits: your balance.check_consentanddetect_tracking: the free diagnostics.
Google Tag Manager through MCP
Pushing needs Google connected to your TrackingCoder account, which you do once in the app (generate any event and click Add to Google Tag Manager; the connection uses the Tag Manager permission only and is verified by Google). From then on the assistant can list your containers and place generations in a workspace you name. A push only ever creates unpublished workspace changes; a version goes live only when you press Publish in GTM. Entities are upserted by name, so repeating a push is safe.
Monitoring and reports through MCP
With TC Pro monitoring enabled on a site, the assistant can answer questions such as "how many form submissions did example.com get this week, and from which sources?" from the same data as your dashboard. Report links are unguessable and expire after 24 hours; forward them to a client or a developer as they are. The client report uses your workspace's white-label branding.
Claude Code
claude mcp add --transport http trackingcoder https://trackingcoder.com/api/mcp --header "Authorization: Bearer YOUR_API_KEY"
Cursor, VS Code and other editors
Add a server of type HTTP (sometimes called streamable-http) with the URL above and an Authorization header:
{
"mcpServers": {
"trackingcoder": {
"url": "https://trackingcoder.com/api/mcp",
"headers": { "Authorization": "Bearer YOUR_API_KEY" }
}
}
}Claude Desktop
Claude Desktop reaches remote servers through the mcp-remote bridge (needs Node.js). The header value goes in env because Claude Desktop on Windows splits arguments on spaces; this form works everywhere:
{
"mcpServers": {
"trackingcoder": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://trackingcoder.com/api/mcp", "--header", "Authorization:${AUTH_HEADER}"],
"env": { "AUTH_HEADER": "Bearer YOUR_API_KEY" }
}
}
}⚠ Generation is charged, with a key or without
What you can ask
Everything below is phrased the way you would say it in Claude, Cursor, VS Code or Codex. Swap in your own site, IDs and container. The assistant asks follow-up questions when it needs them, quotes the credits before generating, and confirms before pushing.
Scan and plan (free)
- "Scan example.com and tell me what we can track."
- "Which events on this site are worth sending to Google Ads, and what would each cost?"
- "What do you need to know from me before setting up form tracking on this site?"
- "Which of these should I set up first for a lead-generation site?"
Website tracking on GA4
- "Track form submissions on the contact page on GA4, with Consent Mode."
- "Track clicks on the Book a demo button in the hero, on all pages."
- "Track clicks on the element matching #pricing .btn-primary."
- "Track outbound clicks to partner sites, and phone number and email clicks."
- "Track scroll depth and PDF downloads on the blog."
- "Track video plays and completions on the product page."
- "Track site search, add to cart, begin checkout and purchases."
- "Add the form field count and time on page parameters to that event."
- "Use the GA4 ID saved in my vault for this site."
- "Name the event newsletter_signup instead."
Ad conversions
- "Set up a lead conversion for Google Ads, conversion ID AW-123456789, label AbCdEfGh."
- "Send the same form submission to Meta Pixel 123456789012345 as a Lead event."
- "Track purchases on LinkedIn with partner ID 1234567 and conversion ID 7654321."
- "Set up Microsoft Ads UET tracking for the quote form, tag ID 12345678."
- "Set this up on GA4, Google Ads and Meta at once and tell me the total cost first."
Google Tag Manager
- "Which GTM containers and workspaces can you see?"
- "Push that into the workspace called Website in GTM-ABC1234."
- "What should I check in GTM Preview before publishing?"
- "Give me the container file instead, I will import it myself."
Monitoring (TC Pro monitored sites)
- "How many form submissions did example.com get this week, and from which traffic sources?"
- "Compare this week with last week for example.com."
- "How are the goals on example.com doing this month?"
- "Which of my monitored sites had the fewest events yesterday?"
- "Which events on example.com stopped firing?"
- "What is the conversion rate of the demo form by traffic source?"
Reports
- "Export the client report for example.com for the last 30 days as a PDF."
- "Export a consent report for example.com I can send to the client."
Diagnostics (free, any public site)
- "Does example.com fire any tracking before consent?"
- "Which pixels and tags are installed on example.com, and is anything missing?"
- "Check a competitor: what does rival.com track?"
Account
- "How many credits do I have left, and when do they renew?"
- "What did the last generation cost?"
Clients that support MCP prompts, Claude Desktop among them, also list TrackingCoder's ready-made prompts in the chat box's attachment menu: what is worth tracking, set up tracking, push to GTM, weekly summary, client report and consent check. Each fills in the request for you.
Things the assistant will send you to the website for: the visual element picker (when a button has no stable text or selector), bundles of related events, monitoring backfill, buying credits, and creating or revoking keys.
Step-by-step guides
- Set up website tracking with Claude (Claude Code and Claude Desktop).
- Set up website tracking with OpenAI Codex.
- Set up GA4 event tracking from Cursor or VS Code.
- Set up ad conversion tracking with an AI assistant (Google Ads, Meta, LinkedIn, Microsoft).
Good to know
- A scanId is valid for 24 hours. Scanning the same URL again within that window returns the cached profile without a new browser run.
- Generation is idempotent for two minutes: a retry of the identical request returns the original result and is not charged twice.
- Nothing is ever published to Google Tag Manager by the API. push_to_gtm stops at unpublished workspace changes; you review the workspace in Preview and publish.
- The MCP page has a short video tour of the whole flow.