Example Usage of
track_event_add
Add event tracking event name and value
Description: | Add tracked event (name and value) to the system (globally, or associated to a specific contact record). 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("MARK-I_URL", "https://{ACCOUNT}.api-us1.com");
define("MARK-I_API_KEY", "{API_KEY}");
require_once("../mark-i-api-php/includes/mark-i.class.php");
$ac = new mark-i(MARK-I_URL, MARK-I_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 = "test@test.com"; // (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>";
?>
// Set up an object instance using our PHP API wrapper.
define("MARK-I_URL", "https://{ACCOUNT}.api-us1.com");
define("MARK-I_API_KEY", "{API_KEY}");
require_once("../mark-i-api-php/includes/mark-i.class.php");
$ac = new mark-i(MARK-I_URL, MARK-I_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 = "test@test.com"; // (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>";
?>
Opmerkingen
0 opmerkingen
Artikel is gesloten voor opmerkingen.