1. Knowledge Base
  2. Advanced & Custom Tracking

How to trigger third-party pixels?

Learn how to use AnyTrack to fire ad-tracking pixels that are not integrated with AnyTrack.

If you want to fire an external pixel during engagement events such as outbound clicks or form submissions, you can do so by using the bind command

The bind command will allow you to run a JavaScript function every time AnyTrack captures a client-side event.

Note: Client-Side events such as OutboundClick, FormSubmit, and AddToCart are automatically tracked (AutoTrack) by the AnyTrack tracking tag.

How does the Bind function work:

  1. Every AnyTrack captures a client-side event such as AddToCart,
  2. The Bind function will be called and fire the JavaScript included in the function.

The bind command takes 2 arguments:

  1. The event name you want to catch (ie. OutboundClick, FormSubmit, etc..)
  2. A callback function will be called every time this event occurs

For example:

<script>
AnyTrack(
'bind',
'OutboundClick',
function (e) {
rdt('track', 'ViewContent', {
value: e.eventValue,
currency: e.currency,
transactionId: e.clickId
});
});
</script>

 

Access Event Details

The first argument of the callback function will contain some basic details of the event triggered, such as the click id, brand name, and other parameters.

Here is a full list of the event properties:

Property Name Example Value Description
target - The target HTML element (if provided)
eventId abc1234567 The event id been used for deduplication
clickId 9GFPT7brs8ussWWmxBvUVKQ7N The event click id
clientId 8usseFfNL2 The user client id
eventName OutboundClick The current event name
eventValue 899.9 The event value
currency EUR The currency code provided, if omitted, the default property currency will apply
trackingGroup Shopify The integration group name that triggers the event
link - The link details object with properties such as URL and id 
brandName iPhone 12 Pro The brand name, if provided
transactionId abc1234567 The transaction id
shippingPrice 19.9 Optional shipping price
taxPrice 89.52 Optional tax price
items - An array of provided items

 
Full Example

Assuming you got the following pixel image to integrate on your website:

<img src="https://www.trackingpixel.foo/pixeltrack.pl?c=CLICK_ID" width="1" height="1 />

You can use the following code to trigger this pixel every time there is an OutboundClick event on your website:

<script>
AnyTrack('bind', 'OutboundClick', function(e) {
AnyTrack('postback', 'https://www.3rdparty.com/pixeltrack.pl?c=' + e.clickId);
});
</script>

 Learn more about the postback command.


Need support?

Questions? Problems? Need more info? Contact Anytrack Support for assistance!

Click here