3rd Party Expense Data
In addition to automatically tracking ROI on ad accounts through the native Facebook and AdWords integrations, SegMetrics allows you to track 3rd Party Expense data. This allows you to track ROI on newsletter campaigns as well as 3rd party advertising systems like Cake and AdRoll.
Expense data can be sent in through the SegMetrics API, either through a standard CURL script, or through a tool like Zapier.
In order to start using the Expense Data API, you'll need the following information, which you can find in your Account Settings:
- SegMetrics API Key
- SegMetrics Account ID
Set up your API Connection
If you don't have your SegMetrics API Key set, you can set it up by following the instructions below.
- Go to your Account Settings, from the gear in the upper-right corner
- If you don't have an API Key, click the Refresh button to generate a new API Key
- Click "Save Changes"
Configure Expense Tracking Through Zapier
- Set up the Trigger to read in your Expense data, either from a 3rd party system, or a file like google SpreadSheets
- For the Action, select "Webhooks by Zapier"
- Choose "POST" and press continue
- Set the URL to be https://api.segmetrics.io/ACCOUNT_ID/direct_marketing/ being sure to replace ACCOUNT_ID with your SegMetrics Account ID.
- Under Headers add the following:
- KEY: Authorization
- VALUE: Basic API_KEY
- Be sure to replace API_KEY with your SegMetrics API Key
- Make sure Payload Type is set to "Form"
- Under DATA add the key "data" (without the parenthesis) and the value should be set to the data you're passing in (see "Data Format" below)
- Click Continue
Configure Expense Tracking Manually
SegMetrics Expense Tracking can also be configured manually. The idea is the same as above, but instead of using Zapier, you'll make a CURL request to the SegMetrics API.
CURL
curl -X POST \ https://api.segmetrics.io/ACCOUNT_ID/direct_marketing/ \ -H 'Authorization: Basic API_KEY ' \ -F 'data=[{"utm_source": "adroll", "spend": 1234.75, "date_created": "2018-04-04"},{"utm_source": "adroll", "spend": 5678, "date_created": "2018-04-05"}]'
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://api.segmetrics.io/ACCOUNT_ID/direct_marketing/"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, [ "Authorization: Basic API_KEY " ]); $result = curl_exec($ch); if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); } curl_close ($ch);
var request = require('request'); var options = { url: 'https://api.segmetrics.io/ACCOUNT_ID/direct_marketing/', method: 'POST', headers: { 'Authorization': 'Basic API_KEY' } }; function callback(error, response, body) { if (!error && response.statusCode == 200) { console.log(body); } } request(options, callback);
Data Format
- date_created - the date of the spend in Y-m-d format
- spend - amount in decimal
- clicks (optional) - the number of clicks for the date as an integer
- impressions (optional) - the number of impressions for the date as an integer
- utm_campaign (optional) - the campaign to attribute the spend to
- utm_source (optional) - the source to attribute the spend to
- utm_medium (optional) - the medium to attribute the spend to
- utm_content (optional) - the content to attribute the spend to
- utm_term (optional) - the term to attribute the spend to