Example Usage of track_event_add
Add event tracking event name and value
Description: | Add tracked event (name and value) to the system (globally). Make sure to enable event tracking before making this call (events added with event tracking disabled will not be saved). | ||||||||||||||
Endpoint: |
https://trackcmp.net/event
|
||||||||||||||
HTTP method: | POST |
||||||||||||||
Supported output formats: | json |
||||||||||||||
Requires authentication: | Yes |
||||||||||||||
Parameters: |
* indicates requirement. Underlined params include in URL, otherwise as part of the post body. POST data must be formatted as
Content-Type: application/x-www-form-urlencoded. We don't accept any other input formats like JSON.
|
||||||||||||||
Example response: |
|
PHP Example
This is an example of using the track_event_add
call with PHP.
You can replicate the same idea in virtually any other programming language.
The example shown is using serialize
as the output format.
You can change that to XML
or JSON
if you would like.
<?php // Set up an object instance using our PHP API wrapper. define("ACTIVECAMPAIGN_URL", "https://{ACCOUNT}.api-us1.com"); define("ACTIVECAMPAIGN_API_KEY", "{API_KEY}"); require_once("../activecampaign-api-php/includes/ActiveCampaign.class.php"); $ac = new ActiveCampaign(ACTIVECAMPAIGN_URL, ACTIVECAMPAIGN_API_KEY); $ac->track_actid = "1111111"; // your unique tracking account ID (found on the Integrations page). $ac->track_key = "hus7dasty..."; // your unique event key (found on the Integrations page). $ac->track_email = "[email protected]"; // (optional) contact email address to associate the event with. $post_data = array( "event" => "my_custom_event", "eventdata" => "12345", // any extra (optional) visit data to include? "visit" => array( "url" => "", "referrer" => "", "ip4" => "", "ip6" => "", "ua" => "", "browser" => "", "platform" => "", "device" => "", "utm_source" => "", "utm_campaign" => "", "utm_medium" => "", "utm_term" => "", "utm_content" => "", ), ); $response = $ac->api("tracking/log", $post_data); echo "<pre>"; print_r($response); echo "</pre>"; ?>
Questions? Discuss this API call in our developer forum