Zernio
APIFor you
Zernio
APIFor you
Platforms

LinkedIn Ads

Overview

Build

Create adsBoost a postLead Gen FormsCreative formats

Target

TargetingMatched AudiencesBid pricing & forecasts

Measure

AnalyticsConversions APIInsight TagURL tracking tags

Operate

Manage adsAd Library

Reference

Media & limits
Dashboard
OverviewPlatformsAPI ReferenceResources
LinkedIn Ads

Targeting

Target LinkedIn ads by country, region and the B2B facets (industry, company size, seniority, job function, title, skill), look up LinkedIn's ids, and change a running campaign's audience.


By the end of this page, a LinkedIn ad reaches the professional audience you describe, and you can change that audience once it runs.

Before you start

You need a linkedinads account and the create call from Create a campaign.

Targeting fields

countries: ['US'] is the minimum LinkedIn accepts.

The professional facets are what LinkedIn Ads are bought for. They go in a nested targeting object on POST /v1/ads/create, the same spec Bid pricing and forecasts prices and sizes before you spend:

{
  "targeting": {
    "countries": ["US", "GB"],
    "industries": ["4"],
    "companySizes": ["D", "E", "F"],
    "seniorities": ["4", "5"],
    "jobFunctions": ["8"]
  }
}
FieldValueMatched as
countriesISO 3166-1 alpha-2 codesLinkedIn geo URNs
regions[{ "key": ... }], each key a urn:li:geo:* URN from the searchThe same locations facet as countries
industriesIndustry id fragmentsurn:li:industry:{id}
companySizesStaff-count codes (below)urn:li:staffCountRange:{range}
senioritiesSeniority id fragmentsurn:li:seniority:{id}
jobFunctionsFunction id fragmentsurn:li:function:{id}
jobTitlesTitle id fragmentsurn:li:title:{id}
skillsSkill id fragments, or urn:li:skill:* URNs from the search (python finds urn:li:skill:1346)urn:li:skill:{id}
interests[{ "id": ... }], each id a URN from the searchThe interests facet
behaviors[{ "id": ... }], each id a urn:li:memberBehavior:* URN from the search, such as Frequent Travelers, Job Seekers or Recently PromotedThe member behaviors facet
audienceInclude, audienceExcludeSegment ids from GET /v1/ads/audiencesurn:li:adSegment:{id}
excludedLocations.countriesISO 3166-1 alpha-2 codesThe exclude clause

A full URN passes through unchanged wherever an id fragment is accepted, so a value straight out of LinkedIn's own tooling works as it is.

companySizes takes a letter per staff-count range:

CodeStaff
A1
B2 to 10
C11 to 50
D51 to 200
E201 to 500
F501 to 1,000
G1,001 to 5,000
H5,001 to 10,000
I10,001 and above

Other facets map to LinkedIn's own:

  • ageMin / ageMax round out to LinkedIn's age buckets: 18-24, 25-34, 35-54, 55+. Nothing under 18.
  • gender maps to LinkedIn's gender facet.
  • languages (ISO 639-1) maps to its interface locale, one per language (default English).

Rules LinkedIn enforces

3 rules decide whether the request survives:

  • LinkedIn requires at least one location. Send none and the ad targets the United States.
  • jobTitles cannot be combined with seniorities or jobFunctions. LinkedIn rejects the whole ad, so Zernio returns a 400 with code mutually_exclusive_fields first.
  • cities, zips, metros, customLocations, incomeTier and Meta's work facets return a 400 with code invalid_field_value naming the field. LinkedIn's Marketing API has no equivalent.
A country code outside the 45 Zernio maps returns 400 invalid_field_value with param countries. Only a request with no location at all falls back to the United States.

Look up LinkedIn ids

Call GET /v1/ads/targeting/search with accountId, q and dimension. On LinkedIn, dimension takes geo, interest, behavior, industry, jobFunction, seniority, companySize and skill.

import Zernio from '@zernio/node';

const zernio = new Zernio();

const { data: search } = await zernio.adtargeting.searchAdTargeting({
  query: {
    accountId: '66b2e19d8c3f5a7e9d0b1c2d',
    q: 'python',
    dimension: 'skill'
  }
});

const skillUrn = search.results[0].id;

Response (200):

{
  "results": [
    { "id": "urn:li:skill:1346", "name": "Python", "type": "skill" }
  ]
}

The B2B dimensions return the full URN to pass straight back, such as urn:li:industry:4 or urn:li:staffCountRange:(51,200).

Only industry and skill are name searches on LinkedIn's side. For job functions, seniorities and company sizes, Zernio fetches LinkedIn's whole table and matches q itself.

A geo search returns every matching level in one list, and LinkedIn ignores geoType and countryCode. A country comes back with type: country and its ISO code as id. Every other place is type: region, with a urn:li:geo:* URN for regions[].key.

Change a running campaign

Send targeting on PUT /v1/ads/{adId}. Zernio writes it to the ad's LinkedIn Campaign, so it applies to every creative in that Campaign.

const { data: updated } = await zernio.adcampaigns.updateAd({
  path: { adId: '66f0a1b2c3d4e5f6a7b8c9d0' },
  body: {
    targeting: {
      countries: ['US', 'GB'],
      seniorities: ['5', '6'],
      companySizes: ['E', 'F', 'G']
    }
  }
});

Response (200) returns the updated ad and a message.

The update merges facet by facet. Zernio reads the live targeting and keeps every facet you do not send. A facet sent empty or null is removed.

An update applies countries or regions, excludedLocations (countries), the B2B facets and audience segments. Any location you send replaces the live locations. Interests, behaviors, age, gender and languages are not applied on update.

If it fails

ErrorCauseFix
400 mutually_exclusive_fieldsjobTitles sent with seniorities or jobFunctionsKeep jobTitles, or the other two
400 invalid_field_value naming a fieldcities, zips, metros, customLocations, incomeTier or a Meta work facetTarget by country, region and the B2B facets
400 on a country codeThe country code is unknownSend an ISO 3166-1 alpha-2 code, or a region URN from the search
400 naming dimensionThe search dimension does not exist on LinkedInUse one of the dimensions above

Related

  • Create a campaign: the create call these fields ride on.
  • Bid pricing and forecasts: price and size a targeting spec before you spend.
  • Matched Audiences: the segments for audienceInclude.
  • Search targeting options and Update ad: every parameter.
Was this page helpful?

Creative formats

Select carousel, document, event, text, spotlight, follower, jobs, conversation and thought-leader ads with one key inside platformSpecificData.

Matched Audiences

Create LinkedIn contact-list, company-list, engagement and website retargeting audiences with POST /v1/ads/audiences.

On this page

Before you startTargeting fieldsRules LinkedIn enforcesLook up LinkedIn idsChange a running campaignIf it failsRelated