What is event tracking?

Event tracking is an advanced feature that allows you to work with our open API data and requires knowledge of programming language.

Event tracking is a flexible application that enables you to collect data on the behaviour of your contacts in the broadest sense. You can create an event for any activity on your website or app and assign a value to it. By starting to collect event data and sending it to your MailBlue account, you can use it to improve your marketing and sales processes, as well as to trigger automations, determine conditions in your segmentations, and personalise campaigns.

Event tracking vs. (web)site tracking

Event tracking is flexible and allows you to track every virtual behaviour of your contacts on your website. For example, you can track video views, button clicks, placed orders, logins, behaviour within an app, and much more. With event tracking, you need to create customised code for each event you want to track on your website.

(Web)site tracking is a type of event tracking. It simply tracks the webpage visits of your contacts. With site tracking, we provide you with a code that you can place on every page of your site. If you only want to track your page visits, we recommend choosing site tracking. To learn how to add this to your site, click here.

How does event tracking work?

Mastery of programming language is required to work with event tracking. If you do not have this knowledge yourself, you could work with someone on your team who has this knowledge or hire someone with this expertise to set it up for you. The MailBlue team does not have this expertise themselves.

To use event tracking, you need to:

  1. Enable event tracking in your MailBlue account (further explanation below)

  2. Choose a programming language on your site to capture the following four data points: who (contact email address) performed the event (defined by yourself), consisting of what value (defined by yourself), and when it occurred.

  3. Use the open API data to send the event data to MailBlue

How do I enable event tracking?

1. In the MailBlue main menu, click on 'Website' > 'Site tracking'. Scroll down a bit and click on the red toggle next to event tracking to enable event tracking:

Screenshot 2024-05-16 at 09.29.20.png

2. The event key will appear in the field highlighted in red in the screenshot below. You need to provide this key when calling the API to send MailBlue the event data you capture on your site. To see the event key in a sample code, click on the 'Event tracking api' link (more information below).

Events will be visible in the box as shown in the screenshot below 'Event', as well as in the condition builder once contacts complete the respective event.

Screenshot 2024-05-16 at 09.34.01.png

Event tracking sample code

The code you use will vary depending on various factors, such as the type of event you want to track. You can generate sample code to use as a starting point. To generate sample code, click on the 'Event tracking api' link as shown in the screenshot below. A new window will open containing a code that includes the account ID and key (highlighted in red in the screenshot below):

Screenshot 2024-05-16 at 09.37.00.png

An event can be triggered by sending 'POST to send' data to https://trackcmp.net/event. This can be done in any programming language. Below is an example of how this can be done using PHP:

 

$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, "https://trackcmp.net/event");

curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($curl, CURLOPT_POST, true);

curl_setopt($curl, CURLOPT_POSTFIELDS, array(

"actid" => 23033,

"key" => "c12973b078007927842301eff932e7d78b74b3e",

"event" => "YOUR_EVENT",

"eventdata" => "ANY_DATA",

"visit" => json_encode(array(

// If you have an email address, assign it here.

"email" => "",

)),

));

$result = curl_exec($curl);

if ($result !== false) {

$result = json_decode($result);

if ($result->success) {

echo 'Success! ';

} else {

echo 'Error! ';

}

echo $result->message;

} else {

echo 'CURL failed to run: ', curl_error($curl);

}

 

Event tracking with the PHP API wrapper

Event tracking with the PHP API wrapper is one of the many ways you can send event tracking data to your MailBlue account. Once you have placed the code on your site to define and track events, you can use the wrapper to send this data to MailBlue. An API wrapper makes it easier to send event data to your account; wrappers can handle API connections and specific API calls as simple functions. This saves you time as you don't have to write API connections and specific API calls from scratch.

 

1. First, you need to define the API data:

define("ACTIVECAMPAIGN_URL", "https://ACCOUNT.api-us1.com");define

("ACTIVECAMPAIGN_API_KEY", "3693354bb1...04c2d126b9c");require_once

("../activecampaign-api-php/includes/ActiveCampaign.class.php");$ac =

new ActiveCampaign(ACTIVECAMPAIGN_URL, ACTIVECAMPAIGN_API_KEY);

 

2. Then set up the tracking details:

$ac->track_actid = "764325673";$ac->track_key = "oy5tbe34c564...

69079d18abc";

You can find the account ID and track key in MailBlue under 'Website' > 'Website-tracking' > 'Event tracking'. Click on the link on that page behind the text 'Event tracking api'.

 

If you want to associate an email address with the event, you can do so as follows:

$ac->track_email = "test@test.com";

If you do not associate an email address here, the event will still be added and available for creating segments based on it in MailBlue.

 

3. Next, set your event data and submit the request:

$post_data = array("event" => "event_name1", // "event_name2", etc.

"eventdata" => "event_value",);$response = $ac->api("tracking/log",

$post_data);

The response will look something like this:

stdClass Object([success] => 1[message] => Event spawned[http_code]

=> 200)

 

Now the event data will appear under 'recent activities' in the contact information of a contact in MailBlue, and you can use the data to create segments within MailBlue.

Was this article helpful?
0 out of 0 found this helpful