Skip to main content

Create a Contextual audience

Create your first audience using IQM's API in this step-by-step quickstart guide.

The following endpoints are used to create a Contextual audience:

POST
POST
GET

About IQM Contextual audiences​

IQM's Contextual audience allows you to make groupings of users based on their online activity. By specifying keywords and/or URLs, IQM builds a Contextual audience as users visit sites relevant to those parameters within a target timeframe.

Contextual audiences have two kinds of data collection periods:

  • static - a timeframe between two dates, from up to 180 days in the past to up to 90 days in the future, with a maximum 60-day period
  • dynamic - a rolling timeframe of up to the last 60 days from today with data refreshing every 24 hours

More resources​

Before you begin​

To create a Contextual audience, the following is required:

  1. An account on the IQM platform
    • See Before you begin section to create an account and request a Client ID and Client Secret

Create a Contextual audience using the IQM API​

This quickstart guide covers how to create a Contextual audience using both keywords and URLs and each type of data collection period.

The minimum requirements to perform this task are: logging in with authentication credentials, creating a Contextual audience, and checking the audience status. Once these steps are accomplished, more can be learned about IQM's API through the guidelines pages.

  1. Log in
    • Optional if you have already logged in and have a token
  2. Create a Contextual audience
  3. Check the audience status

Authentication​

Use the following header parameters for all requests after logging in:

Headers
Authorization
string required
Bearer followed by the access_token from the login response.
See Sign up and authenticate.
X-IAA-OW-ID
integer required
Organization Workspace ID header.

Step 1: Log in​

POST

To log in, send the Authorization: Basic header with your Base64-encoded Client ID and Client Secret, and send the request body as form data (application/x-www-form-urlencoded). The response contains an OAuth access token.

To find the Organization Workspace IDs that you have access to, use Get list of accessible Organizations.

For further information see OAuth token.

Headers
Authorization
string required
Basic followed by your Base64-encoded client_id:client_secret.
See Sign up and authenticate.
Content-Type
string required
application/x-www-form-urlencoded. Send the request body as form data.
Request schema
grant_type
string required
password for login.
See OAuth Grant Types.
username
string required
User account email.
password
string required
User account password.
Request sample
curl -i --location 'https://api.iqm.com/api/v3/ua/oauth/token' \
--header 'accept: application/json, text/plain, */*' \
--header 'Authorization: Basic <base64 of client_id:client_secret>' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=password' \
--data-urlencode 'username=user@iqm.com' \
--data-urlencode 'password=<your password>'
Response 200
{
"access_token": "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIn0...",
"refresh_token": "eyJhbGciOiJIUzUxMiIsInR5cCIgOiAiSldUIn0...",
"scope": "read write",
"token_type": "bearer",
"expires_in": 86399
}
More responses
Response 401
{
"success": false,
"errorObjects": [
{
"error": "Bad Credentials or invalid grant type"
}
]
}
Response 403
{
"error": "Client details are not provided."
}

Step 2: Create a Contextual audience​

POST

You can determine how a Contextual audience forms groupings by indicating a list of relevant keywords and/or URLs. IQM adds users to the Contextual audience when they visit a site relevant to those keywords or URLs.

The request schema table below details the supported fields for creating a Contextual audience. Steps 2a and 2b detail two different ways to perform this action, however keywords and URLs can also be used together to create a Contextual audience.

Request schema
audienceName
string required
Audience name, up to 255 characters.
keywords
array of strings
Keywords to generate a Contextual audience. Send an empty array ([]) if you only use URLs.
urls
array of strings
The publisher sites visited by a user. Each URL must include a scheme (https://). Send an empty array ([]) if you only use keywords.
frequency
integer required
The number of times a user visits the publisher(s) relevant to one or more keywords or URLs added to the Contextual audience, from 1 to 10.
timezoneId
integer required
Timezone ID that sets the data collection start time.
dataCollectionMethodId
integer required
static (1): data collection over a fixed set of dates.
dynamic (2): data collection over a rolling timeframe, with data refreshes every 24 hours.
startDate
integer
Unix epoch start date, in milliseconds. Required if the data collection method is static.
endDate
integer
Unix epoch end date, in milliseconds. Required if the data collection method is static.
dataCollectionDays
integer
Number of days in the rolling data collection timeframe, up to 60. Required if the data collection method is dynamic.
audienceSubtypes
array of integers
Healthcare workspaces only. Audience subtype IDs: 3 (HCP), 4 (Nurse), 5 (Non-NPI Nurse). One audience is created per subtype.

Step 2a: Contextual audience with keywords​

You can create a Contextual audience with keywords and just a few other parameters. You need to pass an audienceName and select one or more keywords. In the provided request sample (seen in the code block in the right-side column) the chosen keywords are "politics", "voters", and "california".

Next you need to decide a frequency from 1-10. This determines how many times a user must visit a site relevant to the chosen keywords to be added to the Contextual audience.

A Contextual audience also requires specifying a timeframe for data collection. In this example you can choose a static data collection method by passing 1 as the dataCollectionMethodId. This method requires Unix Epoch values for the startDate and endDate fields.

info

The start date of a Contextual audience must be within the last 180 days.

Contextual audiences support a static or dynamic data collection period of up to 60 days.

Lastly, a timezone ID is required to determine the data collection timeframe. An ID of 29 designates the US/Eastern time zone.

Request sample
{
"audienceName": "California Politics",
"frequency": 5,
"keywords": ["politics", "voters", "california"],
"urls": [],
"dataCollectionMethodId": 1,
"startDate": 1797310800000,
"endDate": 1800507599000,
"timezoneId": 29
}
Response 200
{
"success": true,
"data": {
"message": "California Politics audience created successfully",
"audienceIds": [
1183879
]
}
}

Step 2b: Contextual audience with URLs​

You can also create a Contextual audience with URLs. You need to pass the desired websites as an array of strings in the urls field.

As in Step 2a, you need to pass integers for frequency and timezoneId.

In this example you can choose a dynamic data collection method by passing 2 as the dataCollectionMethodId. This method requires passing a period of days (1-60) in the dataCollectionDays field.

Request sample
{
"audienceName": "California Politics",
"frequency": 5,
"keywords": [],
"urls": ["https://www.iqm.com"],
"dataCollectionMethodId": 2,
"dataCollectionDays": 20,
"timezoneId": 29
}
Response 200
{
"success": true,
"data": {
"message": "California Politics audience created successfully",
"audienceIds": [
1183878
]
}
}

Step 3: Check audience status​

GET

You can check on the audience status after creation to see if it's Ready (audienceStatusId 3) or still processing. This endpoint also returns various details about the audience as described in the Response properties table below.

Use the ID from the audienceIds array returned in Steps 2a or 2b and pass it as the audienceId in the endpoint path to get the audience's details.

Path parameter
audienceId
integer
Audience ID.
Response properties
audienceId
integer
Audience ID.
audienceName
string
Audience name.
audienceSubtypeId
integer
Audience subtype ID. Returned only for Healthcare audiences created with audienceSubtypes.
audienceStatusId
integer
Audience status ID.
Supported values
1Processing
2Pending
3Ready
4Rejected
5Deleted
6Failed
7Fetching data
8Data fetched
cpm
number
Data cost (CPM) charged if the audience is used in a campaign. Not returned when no data cost applies.
createdAt
integer
Unix epoch creation date, in milliseconds.
reach
integer
Audience reach (unique users). 0 until the audience has data.
keywords
array of strings
Keywords. Not returned when the audience has no keywords.
urls
array of strings
URLs. Not returned when the audience has no URLs.
dataCollectionMethodId
integer
Data collection method: static (1) or dynamic (2).
startDate
integer
Unix epoch start date, in milliseconds (static data collection only).
endDate
integer
Unix epoch end date, in milliseconds (static data collection only).
dataCollectionDays
integer
Number of days in the rolling data collection timeframe (dynamic data collection only).
frequency
integer
Number of times a user must visit a relevant site to be added to the audience.
Response 200
{
"success": true,
"data": {
"audienceId": 1183879,
"audienceName": "California Politics",
"audienceStatusId": 1,
"cpm": 1.5,
"createdAt": 1793041090626,
"reach": 0,
"keywords": [
"politics",
"voters",
"california"
],
"dataCollectionMethodId": 1,
"startDate": 1797310800000,
"endDate": 1800507599000,
"frequency": 5
}
}
Have a question?
Was this page helpful?