Print

Import LinkedIn Pages Data to Google Sheets

In this guide, we will pull data from the LinkedIn Organization (aka Pages) API directly into Google Sheets, using the API Connector add-on for Sheets.

With this connection you should be able to retrieve most of the metrics available to you when you click the Analytics tab while logged into the admin section of your LinkedIn company account. You can also access limited public data about other organizations.

Contents

Before You Begin

Click here to install the API Connector add-on from the Google Marketplace.

Part 1: Connect to the LinkedIn Pages API

The easiest way to get started with the LinkedIn Pages API is through API Connector’s built-in integration.

  1. Select LinkedIn Pages from the drop-down list of applications
    linkedinpages-application
  2. Under Authorization, click Connect to LinkedIn (if you haven't already).
    linkedinpages-authorization
  3. You will be directed to LinkedIn and asked to authorize the connection. Click Allow.
    linkedinads-allow
  4. You’ll now be returned to your Google Sheet, and can verify that your LinkedIn API connection is active.

Part 2: Get your Organization ID

Get your organization ID by looking in the URL while logged into your LinkedIn company page.
linkedin-pages-orgid

Note this ID as we'll need it for our requests.

Part 3: Pull Data from LinkedIn Pages to Sheets

Now that we’re connected, let’s pull some data into Sheets.

  1. Under Endpoint, choose /organizationPageStatistics?q=organization. This will return pageview stats about your organization's LinkedIn page.
    linkedinpages-endpoints
  2. In the Request parameters section, click the organization parameter and select your organization ID from the dropdown menu.
  3. The other required parameter is timeIntervals. Choose a start and end date, as well as a time breakdown (day or month).
  4. Select a destination sheet, name your request, and click Run. A moment later you’ll see a lot of information about your LinkedIn page populate your sheet. This report contains pageviews broken down by multiple facets (device, industry, etc).
    linkedinpages-response
  5. To filter for just the fields you need, click Edit Fields to open API Connector's visual field editor. There you can filter out all the columns you don't want to see in this report.

Part 4: Handle Dates

The LinkedIn Pages API uses UNIX timestamps. Here's how to convert those into standard dates:

  1. Open the field editor by clicking Edit fields
  2. Find the timestamp fields and click the code icons
    linkedinpages-formulaicon
  3. In the dropdown formula menus, select the "UNIX MILLISECONDS TO DATE" option. It will automatically populate with Google's EPOCHTODATE formula
    linkedinpages-selectformula
  4. Click OK and then Save fields
  5. Run the request and the output will automatically show the timestamps as human-readable dates.

Part 5: Create a Custom Request

Alternatively, you can create a custom request instead of using API Connector’s built-in integration, using any of the endpoints and parameters shown in the documentation. Here are a couple example request setups.

Example #1: Get page statistics

Substitute in your own organization ID where it reads 1111111, and your own UNIX timestamps in the timeRange parameter.

  • ApplicationCustom
  • MethodGET
  • Request URLhttps://api.linkedin.com/rest/organizationPageStatistics?q=organization&timeIntervals=(timeRange:(start:1672531200000,end:1703980800000),timeGranularityType:MONTH)&organization=urn%3Ali%3Aorganization%3A1111111
  • OAuthLinkedIn
  • Headers
    • X-Restli-Protocol-Version: 2.0.0
    • LinkedIn-Version: 202401
linkedinpages-customresponse

Example #2: Get posts

As above, substitute in your own organization ID where it reads 1111111

  • ApplicationCustom
  • MethodGET
  • Request URLhttps://api.linkedin.com/rest/posts?author=urn%3Ali%3Aorganization%3A1111111&q=author&count=10&sortBy=LAST_MODIFIED
  • OAuthLinkedIn
  • Headers
    • X-Restli-Protocol-Version: 2.0.0
    • LinkedIn-Version: 202401
    • X-RestLi-Method: FINDER
  • Report Style (under Output options): Grid

Part 6: API Documentation

Official API documentation: https://docs.microsoft.com/en-us/linkedin/marketing/integrations/community-management/organizations/page-statistics

To view or manage the API Connector connection on LinkedIn's side, click this link: https://www.linkedin.com/psettings/permitted-services

14 thoughts on “Import LinkedIn Pages Data to Google Sheets”

  1. Hello Ana,

    I'd like to create triggers for LinkedIn Pages requests to run daily. Is there a way to set a dynamic date range (always yesterday) for these requests? And if so, is it necessary to create a custom request or can it be done directly in LinkedIn Pages?

    Greetings and thanks.

    Reply
    • Hey Luis, for now you need to do this as a custom request. I think the easiest way will be to set up your request using the LinkedIn Pages preset connection, then tick the "Add request URL" option under Output options > More options before you run it. That way you can see your whole request URL and copy/paste it into a custom request. Then instead of hard-coding in the dates, reference cells containing dynamic dates as described here. That article has an example of how to include dynamic dates in your request.
      Update: you can now reference dynamic date cells through the preset integration too, not just through custom requests.

      Reply
    • Good question. Unfortunately the LinkedIn API is really lacking in functionality (and documentation). You can get a list of posts using a request URL like this:
      https://api.linkedin.com/v2/ugcPosts?q=authors&authors=List(urn%3Ali%3Aorganization%3A6447845)&sortBy=LAST_MODIFIED&count=100. However that list doesn't come back with any useful engagement data, and their documentation doesn't seem to indicate that this data is available. I'll update this post if I find anything different.

      Reply
  2. Hello I have followed your tutorial in July 2023 but I have an error, do you know where It can come from ? There is the message : Completed with errors
    - We received an error from linkedin.com (403) show response
    {"status":403,"serviceErrorCode":100,"code":"ACCESS_DENIED","message":"Field Value validation failed in PARAMETER: Data Processing Exception while processing fields [/organization]"}

    Reply
    • I can replicate this error message when I enter an incorrect value to the organizationalEntity parameter. Can you please click the refresh icon next to that field and select one of the values that appears in the dropdown list (rather than entering your own value)? Let me know if you continue to see this error after that.

      Reply
  3. Hi Ana,

    I'm trying to use this endpoint below but it returns the following response: "{"serviceErrorCode":0,"message":"Resource companySearch does not exist","status":404}"

    Is it because that the API connector developer app does not have access to this endpoint?

    https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/organizations/company-search?context=linkedin%2Fcompliance%2Fcontext&view=li-lms-unversioned&preserve-view=true&tabs=http#sample-request

    Reply
    • I'm actually not sure. That page says "The Company Search endpoint is restricted. This permission is granted to selected developers only." but I don't see anything about how we'd apply for access, and we've already been approved for their new Content and Community Management APIs. I'm not sure if this API is even maintained anymore. Our preset integration contains an endpoint for /organizations?q=vanityName, would that help?

      Reply
  4. Hi Ana, I'd like to pull data from personal linkedin pages (w. permission from users). Is that possible? Cheers, Michael

    Reply
    • Hey Michael, LinkedIn generally only lets you fetch data for your own account. If you'd like to fetch data from other pages you'll likely have more luck with an unofficial API, e.g. here.

      Reply

Leave a Comment

Jump To