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 Profile Data into Sheets
- Part 4: More Example API URLs
- Part 5: Notes
- Part 6: Handle Pagination
- Part 7: API Documentation
- Appendix: API Request URL Builder (NEW)
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 basic information about your own LinkedIn account.
- API root: https://api.linkedin.com/v2
- Endpoint: /me
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.
- We don’t need any headers for this API, so just leave that section blank.
- Under Authentication, choose LinkedIn Ads from the Connections dropdown.
- 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.
Part 4: More Example URLs
Now that we’ve validated the connection, we can start pulling some more data. You can access the full list of metrics available in the ads reporting API here, but if you just want to get started, you can try the following URLs.
LinkedIn has a rather inconveniently designed API that returns IDs without names, so I suggest first running all four of these metadata requests so that they’re available when you make your summary reports or dashboards. The metadata is where you can get campaign names, statuses, and other descriptive values.
- List of ad accounts (note the ID that gets returned in the
elements.idfield, we can use this for subsequent requests).
- List of ad campaign groups
- List of ad campaigns (this produces a ton of columns so you can clean it up a bit with a fields parameter like this)
- List of ad creatives
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).
Get Ad Performance
Take a look at these examples, but it’s probably easiest to use the API request builder to create your ad performance requests.
- Summary ad account performance, daily from 2021 (substitute in the account ID value from
elements.idwhere it says 502849368).
Valid timeGranularity values include DAILY, MONTHLY, YEARLY, and ALL
- Summary performance by campaign
- Suggested bid amounts for a campaign targeting LinkedIn members between the ages of 18 and 24
- Campaign reporting for a specific campaign, daily from 2019 (where it says 124782804, substitute in the campaign ID value retrieved from the list of ad campaigns):
Part 5: Notes
- As mentioned above, LinkedIn’s API requires pulling IDs and names separately, and then matching them up. This is easier when you have the ID in the first column to use as a key, so I suggest sorting each response through the visual field editor (click “Edit Fields” before you run your request).
- There are 2 types of calls you can make to the Ads Reporting API:
q=analyticsis the method used in the examples above, and is used when you are only breaking your data down by a single pivot value.
If you have two pivot values, use theAccording to LinkedIn’s documentation, you can pull in multiple pivot values at once with the
q=statisticsquery string, but it doesn’t seem to work reliably.
- 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)
Part 6: 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:
Part 7: 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. It will produce a performance report by ID, so run the metadata request URLs above, too, to get the corresponding account & campaign names. Here’s the link to get your own copy: LinkedIn API Request Builder