Send events from your site
Send leads, bookings and purchases to Pixel Relay with one line of JavaScript, with optional customer details that are hashed.
Once the tracker is installed, page views are sent on their own. Everything else, a form submission, a booking, a purchase, is one call to PixelRelayTracker.track() at the moment it happens.
The basic call
PixelRelayTracker.track('schedule_appointment');
The name is yours to choose. Use lowercase words with underscores, and give each kind of conversion its own name. Then map the name to the Meta event it should count as, here Lead.
Adding a value
The second argument is the event's details. Only these fields are sent on, anything else is dropped:
| Field | Example | Notes |
|---|---|---|
value |
150 |
A number. |
currency |
'GBP' |
Three-letter code. |
content_ids |
['consult-30'] |
Each ID is replaced with a short code before Meta sees it. |
num_items |
2 |
A whole number. |
content_name |
'Consultation' |
Blocked terms are replaced. |
content_type |
'product' |
Blocked terms are replaced. |
content_category |
'Appointments' |
Blocked terms are replaced. |
PixelRelayTracker.track('purchase', { value: 99.5, currency: 'GBP', content_ids: ['consult-30'] });
Adding customer details
The third argument is who the visitor is, when you know it, for example from a form they just sent. Meta uses it to match the event to a person. The relay hashes every one of these with SHA-256 before sending, and never stores them:
| Field | What it is |
|---|---|
email |
Email address |
phone |
Phone number, any format, digits are kept |
first_name |
First name |
last_name |
Last name |
external_id |
Your own ID for the person, like a CRM ID |
form.addEventListener('submit', () => {
PixelRelayTracker.track('schedule_appointment', { value: 150, currency: 'GBP' }, {
email: form.email.value,
phone: form.phone.value,
first_name: form.first_name.value,
});
});
Pass null or {} as the second argument when there are no details: track('lead', {}, { email }).
Never put health details in an event
Do not send what a person booked, their condition or a diagnosis in any field. Event names and fields are for the kind of conversion and its value only. Content names are cleaned of blocked terms, but the safest data is the data you never send.
Shortcuts
The tracker has helpers for Meta's common events. They send the standard names, already in the default mappings:
PixelRelayTracker.trackLead({ email: 'person@example.com' }); // lead
PixelRelayTracker.trackPurchase(99.5, 'GBP', ['consult-30']); // purchase
PixelRelayTracker.trackAddToCart(['consult-30'], 99.5, 'GBP'); // add_to_cart
PixelRelayTracker.trackViewContent('consult-30', 'Consultation', 99.5, 'GBP'); // view_content
PixelRelayTracker.trackInitiateCheckout(99.5, 'GBP', ['consult-30']); // initiate_checkout
All the options and methods are in the tracker reference.
Related articles
Still stuck?
Tell us what you are trying to do and we will help you set it up.