Search API Connector Documentation

Print

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 only supports authentication via OAuth2, so we’ll be connecting using API Connector’s built-in OAuth2 integration for LinkedIn Ads. 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.

OAuth2 is a paid feature, so please upgrade your account or install API Connector for a free trial.

CONTENTS

WHAT DOES THIS INTEGRATION DO?

This integration pulls advertising data from LinkedIn’s API into Google Sheets. It enables the following scopesr_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)

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:

  1. Open up Google Sheets and click Add-ons > API Connector > Manage Connections.
  2. In the list of available connections, find LinkedIn Ads and click Connect.
    linkedin-api-img3
  3. You will be directed to LinkedIn and asked to authorize the connection. Click Allow.
    linkedin-api-img4
  4. You’ll now be returned to your Google Sheet, and can verify that your LinkedIn API connection is active in the Connections screen.
    linkedin-api-img5

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.

https://api.linkedin.com/v2/me

PART 3: PULL LINKEDIN API DATA INTO SHEETS

We can now enter our values into API Connector and start importing LinkedIn data into Google Sheets.

  1. In the Create Request interface, enter the Request URL we just created.
    linkedin-api-img1
  2. We don’t need any headers for this API, so just leave that section blank.
  3. Under Authentication, choose LinkedIn Ads from the Connections dropdown.
    linkedin-api-img6
  4. Create a new tab and click ‘Set current’ to use that tab as your data destination.
  5. Name your request and click Run. A moment later you’ll see some information about your account populate your sheet.
    linkedin-api-img7

PART 4: MORE EXAMPLE API 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. I’m not too familiar with the LinkedIn API, so this is just what I dug up in an hour or two of playing around. If you find any other interesting endpoints, please let me know!

  • List of ad accounts (note the ID that gets returned in the elements » id field, we can use this for subsequent requests).
    https://api.linkedin.com/v2/adAccountsV2?q=search&count=10
  • Ad account performance, daily from 2019 (substitute in the account ID value from elements » id where it says 502849368). Note that LinkedIn now requires a “fields” parameter containing a list of the fields you’d like to retrieve.
    https://api.linkedin.com/v2/adAnalyticsV2?q=analytics&pivot=ACCOUNT&dateRange.start.day=1&dateRange.start.month=1&dateRange.start.year=2019&timeGranularity=DAILY&accounts[0]=urn:li:sponsoredAccount:502849368&fields=externalWebsiteConversions,dateRange,impressions,landingPageClicks,likes,shares,costInLocalCurrency,pivot,pivotValue 
  • Suggested bid amounts for a campaign targeting LinkedIn members between the ages of 18 and 24
    https://api.linkedin.com/v2/adBudgetPricing?account=urn:li:sponsoredAccount:502849368&bidType=CPM&campaignType=SPONSORED_INMAILS&matchType=EXACT&q=criteria&target.includedTargetingFacets.ageRanges[0]=AGE_18_24
  • List of ad campaigns (use Compact report style for cleaner output):
    https://api.linkedin.com/v2/adCampaignsV2/?q=search&count=10
  • 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):
    https://api.linkedin.com/v2/adAnalyticsV2?q=analytics&pivot=CAMPAIGN&dateRange.start.day=1&dateRange.start.month=1&dateRange.start.year=2019&timeGranularity=DAILY&campaigns[0]=urn:li:sponsoredCampaign:124782804&fields=externalWebsiteConversions,dateRange,impressions,landingPageClicks,likes,shares,costInLocalCurrency,pivot,pivotValue
    linkedin-api-img8

PART 5: NOTES

  • Some useful “pivot” (aka breakdown) values include the following (this, and other info comes from https://docs.microsoft.com/en-us/linkedin/marketing/integrations/ads-reporting/ads-reporting):
    • COMPANY – Group results by advertiser’s company.
    • ACCOUNT – Group results by account.
    • CAMPAIGN – Group results by campaign.
    • CREATIVE – Group results by creative.
    • CONVERSION – Group results by conversion.
  • There are 2 types of calls you can make to the Ads Reporting API: q=analytics and q=statistics. q=analytics is 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 the q=statistics query string.
  • As of September 30, 2020, LinkedIn requires that you include the names of fields in your query, up to 15 at a time. You can do so by appending a query string like this: &fields=externalWebsiteConversions,dateRange,impressions,landingPageClicks,likes,shares,costInLocalCurrency,pivot,pivotValue

15 thoughts on “Import LinkedIn Ads Data to Google Sheets”

  1. Can you post an example api using the q=statistics call? I’m trying to pull in multiple pivot values but I can’t seem to get it to work.

    Thanks

    Reply
    • Hey Brian! Can you please try something like this?
      https://api.linkedin.com/v2/adAnalyticsV2?q=statistics&pivots[0]=CAMPAIGN&pivots[1]=CREATIVE&dateRange.start.day=1&dateRange.start.month=1&dateRange.start.year=2019&timeGranularity=DAILY&campaigns[0]=urn:li:sponsoredCampaign:124782804&fields=externalWebsiteConversions,dateRange,impressions,landingPageClicks,likes,shares,costInLocalCurrency,pivot,pivotValues

      That seemed to work for me but I have a pretty limited data set to test on. Let me know how it goes.

      Reply
    • Hi there, can you please try this URL and see if it gets you what you’re looking for?
      https://api.linkedin.com/v2/adCreativesV2?q=search

      Reply
  2. Hi! This was incredibly helpful. Unfortunately all the campaign, campaign groups, creatives, and companies are coming in as numbers instead of using the actual names. So it’s very hard to match up which campaign goes with which campaign code. Is there an API that pulls in the name instead of just the value?

    Reply
    • Hey Kat! Thanks for the message. Can you please try this?
      https://api.linkedin.com/v2/adCampaignsV2/?q=search&count=100

      I believe it will return a list of all your campaigns with both names and IDs, so you can use that to match up the data from the other queries. There might be a better way but that’s how I did it :p. Let me know if that works for you.

      Reply
  3. Hi I was hoping you might be able to give me some guidance.
    I have all the data coming in fine, GREAT JOB, but i’m not able to pull any lead or conversion data from an Ad Campaign that is counting conversions as a download from LinkedIn itself.
    Do you have any ideas the ExternalConversions won’t work because its happening on LinkedIn. Thanks in Advance.

    Reply
    • I can’t say for sure, but if you click this #metrics-available link, you can see all the metrics that LinkedIn provides. I just looked through and some of these look they might be what you’re looking for: actionClicks, adUnitClicks, cardClicks, clicks, companyPageClicks, landingPageClicks, oneClickLeadFormOpens, oneClickLeads, totalEngagements. If you check the link you can see the descriptions of each metric, so please check and see if they get you what you need. If so, you’d just add them into the fields parameter of your request URL. Let me know if that works or you have any questions.

      Reply
  4. I cant seem to do a POST request using LinkedIn Connection?
    What is the reason for this? Is it because it is a paid feature or something else?

    Reply
    • Hey Ben, this is because LinkedIn’s API requires approval for each specific scope (permission). API Connector limits the scopes it requests to r_ads, r_ads_reporting, and r_basicprofile, which only allow getting, not posting, data. Sorry for the inconvenience. One option would be for you to create your own custom OAuth2 connection to Linkedin, then you could request whatever scopes you need. Or could you please let me know a bit more about what you’re trying to do? I will consider requesting additional scopes in the future.

      Reply
      • Hi Ana, I’m looking to generate many ads & campaigns in bulk for an ABM use case where we cite a company name. I have a Custom App with the necessary permissions.
        Maybe I can connect using that Connection using your custom Connection option?

      • Yeah, if you’ve already made your app on LinkedIn’s side, you should be able to set up API Connector’s custom OAuth2 connection like this:
        Name: Custom LinkedIn
        Authorization Base URL: https://www.linkedin.com/oauth/v2/authorization?scope=r_ads,r_ads_reporting,r_basicprofile (add on other scopes here)
        Token URL: https://www.linkedin.com/oauth/v2/accessToken
        Client ID: provided by LinkedIn
        Client Secret: provided by LinkedIn

        Custom OAuth gets added in the Manage Connections screen. As long as you add your ad management scopes to the base URL, you will be able to access whatever you need in LinkedIn’s API. Can you please try that and see how it goes?

Leave a Comment