Integrations / LinkedIn Ads
LinkedIn Ads
LinkedIn Marketing API: list ad accounts and campaigns, pull ad analytics, pause or activate campaigns.
6 actions
OAuth 2
5 read1 write
Calls api.linkedin.com
Connect
const conn = await setu.connections.initiate({ userId: "user_1", toolkit: "linkedinads" });
console.log(conn.connectUrl); // show this to your user
await conn.waitUntilActive();Permissions requested
| Scope | Why it is requested |
|---|---|
r_ads | Read your LinkedIn ad accounts and campaigns |
r_ads_reporting | Read advertising performance reports |
rw_ads | Pause or activate campaigns in your ad accounts |
Actions
Get ad accountreadlinkedinads.get_ad_accountRead one LinkedIn ad account: name, currency, status, serving statuses, reference organization and type.
Needs scope: r_ads
| Input | Type | Description | |
|---|---|---|---|
ad_account_id | string | Required | Ad account id (number), from list_ad_accounts |
await setu.execute({
userId: "user_1",
action: "linkedinads.get_ad_account",
input: {
"ad_account_id": "<ad_account_id>"
},
});Get ad analyticsreadlinkedinads.get_analyticsPerformance report for one ad account over a date range, grouped by one pivot (account, campaign group, campaign or creative). Choose metric fields such as impressions,clicks,costInLocalCurrency,pivotValues,dateRange.
Needs scope: r_ads_reporting
| Input | Type | Description | |
|---|---|---|---|
account_id | string | Required | Ad account id (number), from list_ad_accounts |
start_year | integer | Required | Start year |
start_month | integer | Required | Start month 1-12 |
start_day | integer | Required | Start day |
end_year | integer | Required | End year |
end_month | integer | Required | End month 1-12 |
end_day | integer | Required | End day |
pivot | string | Required | Group results by |
time_granularity | string | Required | Bucket size |
fields | string | Optional | Comma-separated metrics, up to 20; include pivotValues and dateRange |
await setu.execute({
userId: "user_1",
action: "linkedinads.get_analytics",
input: {
"account_id": "<account_id>",
"start_year": 1,
"start_month": 1,
"start_day": 1,
"end_year": 1,
"end_month": 1,
"end_day": 1,
"pivot": "<pivot>",
"time_granularity": "<time_granularity>"
},
});Get campaignreadlinkedinads.get_campaignRead one LinkedIn campaign: name, type, status, cost type, budgets, run schedule and targeting.
Needs scope: r_ads
| Input | Type | Description | |
|---|---|---|---|
ad_account_id | string | Required | Ad account id (number), from list_ad_accounts |
campaign_id | string | Required | Campaign id (number) |
await setu.execute({
userId: "user_1",
action: "linkedinads.get_campaign",
input: {
"ad_account_id": "<ad_account_id>",
"campaign_id": "<campaign_id>"
},
});List ad accountsreadlinkedinads.list_ad_accountsList the LinkedIn ad accounts the connected member can access (id, name, status, currency, type), optionally filtered by status.
Needs scope: r_ads
| Input | Type | Description | |
|---|---|---|---|
status | string | Optional | Optional status filter |
page_size | integer | Optional | Results per page (max 1000) |
page_token | string | Optional | nextPageToken from a previous call |
await setu.execute({
userId: "user_1",
action: "linkedinads.list_ad_accounts",
input: {},
});List campaignsreadlinkedinads.list_campaignsList campaigns in a LinkedIn ad account (id, name, type, status, budget, schedule), optionally filtered by status.
Needs scope: r_ads
| Input | Type | Description | |
|---|---|---|---|
ad_account_id | string | Required | Ad account id (number), from list_ad_accounts |
status | string | Optional | Optional status filter |
page_size | integer | Optional | Results per page (max 1000) |
page_token | string | Optional | nextPageToken from a previous call |
await setu.execute({
userId: "user_1",
action: "linkedinads.list_campaigns",
input: {
"ad_account_id": "<ad_account_id>"
},
});Pause or activate campaignwritelinkedinads.set_campaign_statusSet a LinkedIn campaign's status to PAUSED or ACTIVE using a partial update. Activating can start spending money; needs a campaign-manager or higher role on the ad account.
Needs scope: rw_ads
| Input | Type | Description | |
|---|---|---|---|
ad_account_id | string | Required | Ad account id (number), from list_ad_accounts |
campaign_id | string | Required | Campaign id (number) |
status | string | Required | New status |
await setu.execute({
userId: "user_1",
action: "linkedinads.set_campaign_status",
input: {
"ad_account_id": "<ad_account_id>",
"campaign_id": "<campaign_id>",
"status": "<status>"
},
});