Skip to content
TrackPilot

Install the tracking script

Where to paste t.js, how it wraps fbq, Google Tag Manager, and the trk() JavaScript API.

Where to paste it

Paste your install code inside <head> on every page, before the Meta Pixel snippet:

<script src="https://cloudbase.click/v1/t.js?id=sk_your_site_key"></script>

<!-- Meta Pixel Code (unchanged) -->
<script>
  !function(f,b,e,v,n,t,s){ /* … */ }(window, document,'script','https://connect.facebook.net/en_US/fbevents.js');
  fbq('init', '123456789012345');
  fbq('track', 'PageView');
</script>

The script is small and loads before the pixel so it can wrap fbq. Keep the pixel code exactly as it is.

What it does

  • Every fbq('track', …) and fbq('trackCustom', …) call gets an eventID (unless you set one), and the same event is sent to our server with that ID.
  • For Purchase with an order_id or transaction_id parameter the ID is purchase_<order id> — the same ID our WordPress plugin and your server use, so all three deduplicate.
  • _fbp and _fbc (from fbclid in ad clicks) are kept as first-party cookies on your domain for 90 days.

Google Tag Manager

  1. New tag → Custom HTML → paste the install code. Trigger: All Pages (or Initialization – All Pages).
  2. Make it fire before your Meta Pixel tag: give it a higher Tag firing priority, or use Tag sequencing on the pixel tag ("Fire a tag before…").
  3. Publish, then check the Event log.

JavaScript API

You rarely need it, but the script exposes trk():

// send an event only to the server (no browser pixel call)
trk('track', 'Lead', { value: 500, currency: 'BDT' }, { eventID: 'lead_8812' });

// add customer data for better matching (hashed before it is stored)
trk('user', { em: '[email protected]', ph: '8801712345678', fn: 'Rahim', external_id: 'cust_42' });

// consent (only when the site requires consent)
trk('consent', true);

Accepted user fields: em, ph, fn, ln, ct, st, zp, country, ge, db, external_id. Phone numbers should include the country code (880… for Bangladesh).


Stuck? Ask for setup help — we answer in বাংলা or English.