Syncing audiences from Snowflake to LinkedIn Ads
Set your Polytomic API key as an environment variable:
This example covers six steps:
- Create a Snowflake Connection.
- Create a LinkedIn Ads Connection.
- Create a model from a Snowflake query.
- Inspect the available audiences in LinkedIn Ads.
- Sync data into an existing LinkedIn Ads audience.
- Create a new audience and populate it from Snowflake.
1. Create a Snowflake connection
The Snowflake instance must be reachable from Polytomic over the network. For details, see the Snowflake connection guide.
cURL
Python
Typescript
Go
2. Create a LinkedIn Ads connection and select accounts
The following request creates a LinkedIn Ads Connection. See the LinkedIn Ads connection configuration for the required fields.
cURL
LinkedIn Ads Connections authenticate with OAuth. Open the URL returned in the auth_url field of the response to complete the flow.
OAuth redirection
By default, the API expects auth_url to open in a new browser window.
Set the optional redirect_url parameter in the request body to change
the redirect target.
A LinkedIn Ads Connection can pull data from multiple ad accounts. To choose which ones, fetch the available connection parameters, then update the account list on the Connection.
cURL
Use those values to update the Connection.
cURL
3. Create a Snowflake model
Create a model backed by a Snowflake query:
cURL
Python
Typescript
Go
Enumerating model sources
For information about how to enumerate sources, see this example.
4. Inspect the available audiences
Retrieve the audiences available on a LinkedIn Ads Connection by listing the target objects for that Connection.
cURL
Python
Typescript
Go
5. Sync into an existing audience
To write to an existing LinkedIn Ads audience, set the audience ID as the target object on the sync.
The following sync maps email, first_name, and last_name from the Snowflake model to the corresponding LinkedIn Ads fields. Add more entries to the fields array to sync additional columns.
cURL
6. Create a new audience and populate it
To write to a new audience, pass the audience’s creation properties in the target object of the sync request.
The required properties come from the target_creation section of the target objects list response.
The Step 4 response shows that LinkedIn Ads supports creating destinations and requires three properties:
accounttypename
Both account and type are marked "enum": true, so you can fetch their allowed values from the property values endpoint.
Fetching account returns the ad accounts enabled on the Connection:
cURL
Fetching type returns the supported audience types:
cURL
Instead of setting a target object, pass these properties as a create object on the target. For example:
