Search API Connector Documentation
Import LinkedIn Ads Data to Google Sheets
In this guide, we will pull data from the LinkedIn API directly into Google Sheets, using the API Connector add-on for Sheets.
The LinkedIn API is extremely limited and blocked off; don’t expect a way to pull out profile information for anyone but yourself. However, this API is perfect for pulling out advertising performance data from the LinkedIn Ads Reporting API.
- Before You Begin
- Part 1: Connect to the LinkedIn Ads API
- Part 2: Create a LinkedIn API Request URL
- Part 3: Pull LinkedIn API Data into Sheets
- Part 4: More Example API URLs
- Part 5: Handle Pagination
- Part 6: Notes
- Part 7: LinkedIn API v1.0 vs v2.0
- Part 8: API Documentation
- Appendix: API Request URL Builder (UPDATED)
Before You Begin
Click here to install the API Connector add-on from the Google Marketplace.
Part 1: Connect to the LinkedIn Ads API
If you haven’t connected API Connector to LinkedIn before, you’ll first need to initiate the connection as follows:
- Open up Google Sheets and click Extensions > API Connector > Manage Connections.
- In the list of available connections, find LinkedIn Ads and click Connect.
- You will be directed to LinkedIn and asked to authorize the connection. Click Allow.
- You’ll now be returned to your Google Sheet, and can verify that your LinkedIn API connection is active in the Connections screen.
Part 2: Create a LinkedIn API Request URL
For our first request, we’ll get some IDs and other information about your advertising accounts.
- API root: https://api.linkedin.com
- Endpoint: /v2/adAccountsV2
- Parameters: ?q=search&count=10
Putting it together, we get the full API Request URL.
Part 3: Pull LinkedIn API Data into Sheets
Now let’s copy that URL into API Connector.
- In the Create Request interface, enter the Request URL we just created.
- Under OAuth, choose LinkedIn Ads. You should see a “connected” badge.
- We don’t need any headers for this API, so just leave that section blank.
- Create a new tab and click Set current to use that tab as your data destination.
- Name your request and click Run. A moment later you’ll see some information about your account populate your sheet.
- Pay special attention to the account IDs listed under elements.id as we’ll use those in later requests.
Part 4: More Example URLs
The easiest way to create your request URL is through the API request builder. However, you can check out the examples below to get an idea of how it all works. For each example, substitute in the account ID value from elements.id where it says 502849368.
Note: By default, LinkedIn’s API returns IDs without names, so these example URLs use a parameter called projection, which allows us to fetch associated metadata in a single request (info). The examples show how to filter the projected fields for just a few key metrics like names and status. If you’d rather return all available fields, replace the projection snippet with
To filter for active campaigns or creatives, you’d add a filter like this to the end of your URL:
&search.status.values=ACTIVE. Other filters are shown in LinkedIn’s API documentation under “Search for Campaigns” (link).
Part 5: Handle Pagination
For certain endpoints, LinkedIn’s API limits response data as described here:
To use API Connector’s automatic pagination handling, use offset-limit pagination as follows
- Offset parameter:
- Limit parameter:
- Limit value:
- Run until: choose when to stop fetching data
Part 6: Notes
- Use the visual field editor to re-arrange columns (just click Edit Fields before running your request).
- LinkedIn sends back dates split into separate year, month, and day fields. To transform these into a regular Sheets date, set a data destination of cell B1, and then add the following function into cell A1:
=arrayformula(if(J2:J<>"", date(J2:J,H2:H,I2:I),"")). The function assumes years are in column J, months are in H, and days are in I; adjust as needed.
- This integration pulls advertising data from LinkedIn’s API into Google Sheets. It enables the following scopes:
r_ads(retrieve your advertising accounts),
r_ads_reporting(retrieve reporting for your advertising accounts), and
r_basicprofile(use your basic profile including your name, photo, headline, and current positions)
- To view or edit the connection, click here: https://www.linkedin.com/psettings/permitted-services
Part 7: LinkedIn API v1.0 vs. v2.0
LinkedIn currently supports two protocol versions: 1.0 and 2.0. There are several minor but important syntax differences in the way API requests are constructed.
- In v1.0, no headers are required. In v2.0, all calls require a Header of Key = X-Restli-Protocol-Version, Value = 2.0.0.
- In v1.0, dates are entered like
&dateRange.start.year=2020&dateRange.start.month=1&dateRange.start.day=1&dateRange.end.year=2022&dateRange.end.month=3&dateRange.end.day=31. In v2.0, this is entered in a more abbreviated form:
- In v1.0, query parameters are represented as an array, like this:
&accounts=urn:li:sponsoredAccount:502849368. In v2.0, a List syntax is used instead:
- All differences are detailed here: https://docs.microsoft.com/en-us/linkedin/shared/api-guide/concepts/protocol-version
Part 8: API Documentation
Official API documentation: https://docs.microsoft.com/en-us/linkedin/marketing/integrations/ads-reporting/ads-reporting
Appendix: API Request Builder
This is a convenient tool for easily building LinkedIn API request URLs. Enter your account ID and select your dates, pivot dimension, and fields.
Once you’ve constructed your URL, you can copy and paste it into API Connector’s request URL input field. Here’s the link to get your own copy: LinkedIn API Request Builder