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: Pull Data from LinkedIn Ads to Sheets
- Part 3: Create a Custom API Request
- Part 4: Fetch and Append New Data
- Part 5: Handle Pagination
- Part 6: Notes
- Part 7: API Documentation
Before You Begin
Click here to install the API Connector add-on from the Google Marketplace.
Part 1: Connect to the LinkedIn Ads API
The easiest way to get started with the LinkedIn Ads API is through API Connector’s built-in integration.
- Select LinkedIn Ads from the drop-down list of applications
- Under Authorization, click Connect to LinkedIn Ads
- 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.
Part 2: Pull Data from LinkedIn Ads to Sheets
Now that we’re connected, let’s pull some data into Sheets.
- Under Endpoint, choose
/adAccountsV2?q=search. This will return your account ID(s), which we can use in subsequent requests.
- There are no other required parameters for this endpoint, so just select a destination sheet, name your request, and click Run. The account IDs are listed in the
- Now select the
/adAnalyticsV2?q=analyticsendpoint to get reporting data in your sheet.
- Under Request parameters, add your account ID using this format:
List(urn%3Ali%3AsponsoredAccount%3A111111111). LinkedIn will only recognize this encoded value so copy and enter it exactly as written, substituting in your own account ID for
- Fill in the other required parameters:
timeGranularity. Optionally enter the text
projectionfield. This will retrieve some additional useful fields like campaign names (without using projection, you'll get just the IDs).
- Run your request.
Part 3: Create a Custom API Request
Alternatively, you can create a custom request instead of using API Connector’s built-in integration. To create a custom request, add the complete URL into the request URL field, select LinkedIn Ads from the OAuth menu, and add a Header of Key =
X-Restli-Protocol-Version, Value =
To easily convert your preset request to a custom request, click Output Options > More Options > Add Request URL before running your request. This will print your URL into your sheet where you can copy/paste it.
Part 4: Fetch and Append New Data
Rather than retrieving the entire data set each time you run your request, you can set your request to fetch new data only. There are a few approaches you could take; here’s one:
- For this example, we'll create a custom request. As mentioned above, you can convert your preset integration into a custom request by clicking Add Request URL. Make sure to also include the Header of Key =
X-Restli-Protocol-Version, Value =
- Run an initial request like
- Use the field editor to select just the fields you want and assign them to specific columns in your report.
- Create a new sheet called Inputs that contains date functions in the format required by LinkedIn, e.g.
=text(today()-1,"dd"). (You can adjust these date functions to get the time slice you need, e.g. here's how to dynamically pull in the last day of the month).
- Switch your request to Append mode and reference those dynamic dates in your request URL like this:
- This will ensure that each request only retrieves data from within the bounds of your dynamically updated dates, and append mode will add that new data to the end of your existing dataset.
- Set your request to run on a schedule. You won’t need to update your request again.
Part 5: Handle Pagination
By default, LinkedIn's
/adAnalyticsV2 endpoint will return just 1000 records. To return more, apply API Connector's automatic pagination handling as follows
next page URL
- Next page path:
- 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.
- To view or manage the connection on LinkedIn, click here: https://www.linkedin.com/psettings/permitted-services
Part 7: API Documentation
Official API documentation: https://docs.microsoft.com/en-us/linkedin/marketing/integrations/ads-reporting/ads-reporting