Setting up Event Tracking with our API wrapper

You can track custom website events using our PHP API wrapper. This is an alternative method of sending Event Tracking data to ActiveCampaign.

First, define your API credentials:

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);

 

Then set up your tracking details:

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

 

You can find the account ID and key values on the “My Settings” > “Tracking” page. Click the link that says “Event Tracking API:”

If you want to associate an email address with the event, add it like this:

 

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

 

If you don’t associate an email address, the event will still be added and available for creating a segment.

Next, set your event data and submit the request:

$post_data = array(
"event" => "checkout", // "abandoned_cart", etc.
"eventdata" => "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 event data will appear in your contact's Activity Stream on the Contact Record and you'll be able to use Event Tracking data to create segments.

Have more questions? Submit a request