How to create a new campaign (group) api+php

In ClickMeter campaigns represent a group of datapoints (tracking links or tracking pixels).
Following is an example in PHP code on how to create a new group (campaign).

$url = '';
$cm_api_key = ''; // add your api key here
//set POST variables
$fields = array(
                                                                                                'name' => 'testGroup',
                                                                                                'notes' => 'Little description...'
$fields_json = json_encode($fields);
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-Clickmeter-Authkey: '.$cm_api_key, 'Content-Type: application/json'));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, count($fields));
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_json);
//execute post
$result = curl_exec($ch);
if($result === false){
echo "Error Number:".curl_errno($ch)."<br>";
echo "Error String:".curl_error($ch);
//close connection


Have more questions? Submit a request


Article is closed for comments.