Tracking script
Install
Add the two lines from Settings → Install to every page. The first line queues calls made before the script loads, so none are lost. On a healthcare site, add it to marketing pages only, never to intake, checkout or patient pages.
Events from the page
wp('track', 'generate_lead'); // a lead form was submitted
wp('track', 'product_added_to_cart');
wp('track', 'checkout_started');
wp('consent', 'granted'); // after your consent banner says yesGA4 events your site already pushes to dataLayer (from GTM, Shopify and most checkouts) are read automatically: begin_checkout, add_to_cart, purchase and the rest count as the same steps as Trakbolt's standard events. Add data-datalayer="off" to the script to turn that off. Only the event name and, for a purchase, the order id, value and currency are read; never personal data or item names.
Identify visitors
When someone submits your form, tell Trakbolt who they are, the same way you would with Mixpanel or Segment. Their browser, with every visit and campaign it came from, then joins their profile, and a later lead or order from your server lands on the same person.
form.addEventListener("submit", function () {
wp('identify', { email: form.email.value, phone: form.phone.value, name: form.name.value });
wp('track', 'generate_lead');
});Email and phone are hashed on arrival. The name, email and phone are kept readable only when your workspace stores contact details. Healthcare workspaces ignore identify: no contact data is taken from site pages.
Button clicks
Links into your partner app are counted on their own, named by their text. Name any other button with data-wp-cta and each click is counted under that name (Sessions → Button clicks).
<button data-wp-cta="Book a call">Book a call</button>
Joining visits to orders
- Partner app hosts: when your funnel continues on another domain (app.example.com), links there carry the visitor id, and that domain's referrals are not counted as a new source.
- Join parameters: if your system adds its own id to links (?ref_id=…) and sends it back with the order, Trakbolt joins on it. It can also read the id from your site's own cookie.
- Visitor cookie:
wp_vid, on your domain and its subdomains when a cookie domain is set (Settings → General), so www and the bare domain count as one visitor.
Click ids Trakbolt reads
From the landing address, in this order of priority (the referral program's id first):
| Click id | Channel |
|---|---|
grsf | Referral program |
gclid | |
gbraid | |
wbraid | |
dclid | |
fbclid | Meta |
msclkid | Microsoft Ads |
ttclid | TikTok |
epik | |
rdt_cid | |
sccid | Snapchat |
twclid | X |
li_fat_id | |
qclid | Quora |
oppref | ChatGPT ads |
Ad tracking templates
Click ids are enough to credit a channel. To see campaigns, ads and keywords, add the platform's tracking template too (also shown under Settings → Integrations). Ids are fine: once the account's spend is imported, campaigns that arrive as ids are shown by name.
| Platform | Template | Where |
|---|---|---|
| Google Ads | {lpurl}?utm_source=google&utm_medium=cpc&utm_campaign={campaignid}&utm_content={creative}&utm_term={keyword} | Account settings → Tracking → Tracking template (account level, so every campaign gets it). Recommended. Keep auto-tagging on so every click still carries its gclid. If a final URL already has a query string, Google joins the parameters with & itself. Campaigns arrive as ids and are shown by name once Google Ads spend is imported. |
| Meta (Facebook / Instagram) | utm_source=facebook&utm_medium=paid&utm_campaign={{campaign.id}}&utm_content={{ad.id}} | Ad → Tracking → URL parameters |
utm_source=pinterest&utm_medium=paid&utm_campaign={campaignid}&utm_content={adid} | Ad → Destination URL parameters | |
utm_source=reddit&utm_medium=paid&utm_campaign={{CAMPAIGN_ID}}&utm_content={{AD_ID}} | Ad → URL parameters | |
| Snapchat | utm_source=snapchat&utm_medium=paid&utm_campaign={{campaign.id}}&utm_content={{ad.id}} | Ad → Website URL parameters |
| TikTok | utm_source=tiktok&utm_medium=paid&utm_campaign=__CAMPAIGN_ID__&utm_content=__CID__ | Ad → URL parameters |
| Microsoft Advertising | {lpurl}?utm_source=bing&utm_medium=cpc&utm_campaign={CampaignId}&utm_content={AdId} | Account → Tracking template |
Consent
| Setting | What the script does |
|---|---|
| Collect unless the visitor opts out | Visits are counted from the first page. When your banner records a no, the visitor id is deleted and nothing more is sent. |
| Collect only after consent | Nothing is stored and no visitor id is set until your banner records a yes. Use this where the law asks for opt-in (EU, UK). |
Bots and test browsers
Crawlers, link previews, uptime monitors and headless browsers are dropped before anything is stored (Settings → Bot traffic). Browsers opened with ?wp_test=1, or carrying your own test cookie, are kept but flagged: they never count in reports or reach an ad platform.