Adding users to a LinkedIn Ads audience
Before getting started make sure to set your Polytomic API key as an environment variable:
This tutorial will cover 6 steps:
- Connecting to Snowflake.
- Connecting to LinkedIn Ads.
- Creating a model using a Snowflake query.
- Inspecting available audiences in LinkedIn Ads.
- Syncing data into an existing LinkedIn Ads audience.
- Creating a new audience and populating it with data from Snowflake.
1. Create an Snowflake Connection
The Snowflake instance must be network-accessible from Polytomic. For more information, see our Snowflake connection guide.
cURL
Python
Typescript
Go
2. Create a LinkedIn Ads connection and select accounts
The following request will create a LinkedIn Ads connection. The configuration for each type of connection can be found at the connection configuration page.
cURL
LinkedIn Ads connections use OAuth for authentication, so the user needs to follow the link returned in auth_url in order to complete the connection.
OAuth Redirection
By default, the API expects the auth_url to be opened in a new browser window. If you’d like to modify the redirect behavior, there is an optional redirect_url parameter that can be added to the request body.
LinkedIn Ads connections support multiple accounts. To configure the accounts enabled for the connection, you fetch the available connection parameters, and then update the account.
cURL
The values returned can be used to update the connection.
cURL
3. Create a Snowflake data model
cURL
Python
Typescript
Go
Enumerating model sources
For information about how to enumerate sources, see this example.
4. Inspecting available audiences in LinkedIn Ads
You can retrieve the available audiences for a LinkedIn Ads connection by listing the target objects (destinations) for the connection.
cURL
5. Syncing data into an existing LinkedIn Ads audience.
To sync data into an existing LinkedIn Ads audience, you need to specify the audience ID as the target object in your sync.
This sync maps the email field in the data model to the email field of
Salesforce Contacts. It additionally maps the FirstName and LastName fields.
You can augment the list of field mappings to sync additional fields.
cURL
6. Creating a new audience and populating it with data from Snowflake.
To create a sync that writes to a new audience, you need to provide the
properties needed to create the audience in the target object of the sync
request.
The properties needed to create the audience can be found in
target_creation
details included in the target objects
list response.
From the response in step 4, we can see that LinkedIn Ads supports creating destinations, and that 3 properties are needed:
accounttypename
The acount and type properties both specify "enum": true, so the available
values can be fetched using the property
values endpoint.
Fetching the account property values returns the Ad Accounts enabled for the
connection.
cURL
Fetching the type property values returns the audience types supported.
cURL
Rather than specifying a target object in the sync request, these properties
are passed as a create object. For example,
