Set up retargeting pixels, track user behavior, and build audiences for precision ad targeting. Re-engage visitors who showed interest but did not convert.
Retargeting (also called remarketing) lets you show ads to users who have previously interacted with your website, app, or event pages. By tracking user behavior through a lightweight pixel, you can build audiences of engaged visitors and serve them highly relevant ads to drive conversions.
Create a pixel via the API or SDK. Each pixel is scoped to your tenant and generates a unique pixel ID.
import { AdsClient } from '@eventzr/ads-client';
const client = new AdsClient({
baseUrl: 'https://api.eventzr.com/ads/v1',
tenantId: '<your-tenant-id>',
accessToken: '<jwt>',
});
const pixel = await client.pixels.create({
name: 'Main Website Pixel',
domain: 'yoursite.com',
trackingEvents: ['pageview', 'purchase', 'add_to_cart', 'signup'],
});
console.log('Pixel ID:', pixel.data.id);
// => px_abc123xyzAdd the following snippet to the <head> of every page on your website. Replace px_abc123xyz with your pixel ID.
<!-- EventZR Retargeting Pixel -->
<script>
!function(e,v,t,z,r){
e.EzrPixel=r;e[r]=e[r]||function(){
(e[r].q=e[r].q||[]).push(arguments)
};
var s=v.createElement('script');
s.async=true;
s.src='https://cdn.eventzr.com/pixel/v1/ezr-pixel.min.js';
v.head.appendChild(s);
}(window,document,'script','','ezrp');
ezrp('init', 'px_abc123xyz');
ezrp('track', 'pageview');
</script>
<!-- End EventZR Retargeting Pixel -->The pixel script is 2.8 KB gzipped and loads asynchronously. It does not block page rendering.
Beyond automatic pageview tracking, fire custom events when users take meaningful actions. These events power your retargeting audiences.
// When a user completes a purchase
ezrp('track', 'purchase', {
value: 99.99,
currency: 'USD',
orderId: 'order_12345',
items: [
{ id: 'ticket_vip', name: 'VIP Ticket', price: 99.99, quantity: 1 }
]
});// When a user adds an item to their cart
ezrp('track', 'add_to_cart', {
itemId: 'ticket_general',
itemName: 'General Admission',
value: 49.99,
currency: 'USD',
});// When a user signs up or registers interest
ezrp('track', 'signup', {
method: 'email',
});// Track any custom event for audience building
ezrp('track', 'view_event_page', {
eventId: 'evt_summer2026',
eventCategory: 'conference',
});| Event | When to Fire | Key Parameters |
|---|---|---|
| pageview | Every page load (auto-tracked) | url, referrer |
| purchase | Checkout completed | value, currency, orderId, items |
| add_to_cart | Item added to cart | itemId, value, currency |
| signup | User registration | method |
| view_content | Product or event page viewed | contentId, contentType |
| search | Search query executed | query, resultsCount |
| lead | Lead form submitted | formId, value |
| initiate_checkout | Checkout started | value, currency, items |
Create audiences based on pixel events. Audiences update in real-time as new events are captured.
// Audience: Users who viewed event pages but didn't purchase in the last 30 days
const audience = await client.audiences.create({
name: 'Viewed Events - No Purchase (30d)',
type: 'retargeting',
pixelId: 'px_abc123xyz',
rules: [
{
event: 'view_content',
params: { contentType: 'event' },
window: '30d',
},
],
exclusions: [
{
event: 'purchase',
window: '30d',
},
],
lookbackWindow: '30d',
});
// Audience: Cart abandoners (added to cart but didn't purchase in 7 days)
const cartAbandoners = await client.audiences.create({
name: 'Cart Abandoners (7d)',
type: 'retargeting',
pixelId: 'px_abc123xyz',
rules: [
{ event: 'add_to_cart', window: '7d' },
],
exclusions: [
{ event: 'purchase', window: '7d' },
],
});Create separate audiences for high-intent (add-to-cart, initiate-checkout) and low-intent (pageview) visitors. Allocate higher bids to high-intent segments.
Set a frequency cap (e.g., 3 impressions per user per day) to avoid ad fatigue and negative brand perception.
Always exclude users who already purchased. Use the exclusions array when defining audiences to avoid wasting budget.
Shorter lookback windows (7 days) have higher intent. Use 30-day windows for broader reach and 7-day windows for urgency campaigns.
Use dynamic creatives that show the specific event or product the user viewed. Personalized ads see 2-3x higher click-through rates.
Honor DNT (Do Not Track) headers and cookie consent. The pixel automatically respects browser privacy settings and GDPR opt-outs.