How to connect LinkedIn Ads API to Google Sheets

LinkedIn Ads are paid advertisements on LinkedIn. We can use the LinkedIn API to import data from LinkedIn Ads into Google Sheets. In this tutorial, I’ll show you how to connect the LinkedIn Ads API to Google Sheets in 7 steps:

  1. Install the Apipheny add-on
  2. Create an app
  3. Access Marketing APIs
  4. Generate an access token
  5. Choose a LinkedIn Ads API endpoint URL
  6. Enter the LinkedIn Ads API Request into the Apipheny add-on
  7. Run the LinkedIn Ads API request

Step 1.) Install and open the Apipheny add-on in Google Sheets

To pull data from the LinkedIn Ads API to Google Sheets, first install and open the Apipheny Google Sheets add-on.

Apipheny is a no-code API integrator for Google Sheets that you can use to make unlimited API requests, connect to unlimited APIs, save API requests, schedule API requests, and more. 

1. Install Apipheny by opening the following link on desktop and then clicking the Install button on the page: https://apipheny.io/install.

Install Apipheny in the Google Workspace Marketplace
Install Apipheny in the Google Workspace Marketplace

2. After you’ve installed Apipheny, open a Google Sheet and then click on the Add-Ons or Extensions option in the top menu. In the add-ons menu, you should see Apipheny.

Click Apipheny > Import API to open the Apipheny sidebar in your Google Sheets.

Opening the Apipheny add-on in Google Sheets
Opening the Apipheny add-on in Google Sheets

Step 2.) Create an App

In your Linkedin developer account, click the Create app button:

Developer account dashboard
Developer account dashboard

Complete all the required fields, such as App name, LinkedIn page and App logo:

Create an app section
Create an app section

Check the terms agreement checkbox and then click the Create app button:

Terms agreement
Terms agreement

Your app will then be created:

App settings section
App settings section

Step 3.) Access Marketing APIs

Select one of your apps then navigate to the Products tab. Select Marketing Developer Platform and agree to the terms.

Products section
Products section
Marketing Developer Platform Access
Marketing Developer Platform Access

Next, complete the MDP Access Form, which is available in the Developer Portal under My Apps > Products. Click the View access form link to start completing the form. Your application will not be reviewed until you complete the survey.

Access form link
Access form link

Complete all the required fields in the form:

Completing the access form - part 1
Completing the access form – part 1

Click the Submit button to finish and save the form:

Completing the access form - part 2
Completing the access form – part 2

A confirmation message will be displayed on the screen. Wait until your developer application has been given access to the Marketing Developer Platform:

Access form confirmation
Access form confirmation

Step 4.) Generate an access token

Go to the LinkedIn Developer Portal, select the app you’ll be using, navigate to the Auth tab, and locate your Client ID and Client Secret. On the same page complete the Authorized redirect URIs for your app:

Auth tab
Auth tab

To proceed, you’re going to need to use a Postman account. If you don’t have one, you can sign up at www.postman.com. Open a new tab in Postman and navigate to Authorization. Change the “TYPE” to “OAuth 2.0” and then complete the fields from the Configure New Token section:

Fill out the form with the following values and click the Request Token button:

  • Grant Type = Authorization Code
  • Callback URL (Redirect URL in LinkedIn terminology) = {your redirect URI from the app}
  • Auth URL = https://www.linkedin.com/oauth/v2/authorization
  • Access Token URL = https://www.linkedin.com/oauth/v2/accessToken
  • Client ID = {Copy this from the “Auth” tab in the developer portal}
  • Client Secret = {Copy this from the “Auth” tab in the developer portal}
  • Scope = r_basicprofile, r_organization_social,rw_ads, r_ads_reporting, r_ads, w_organization_social, w_member_social, r_1st_connections_size, rw_organization_admin
  • Client Authentication = choose the Send client credentials in body option from the dropdown list.
Postman authorization tab
Postman authorization tab

Postman will take you to the LinkedIn authorization page. You may be prompted to log into LinkedIn before getting to the below screen. Click the Allow button to authorize the request.

Authorize the request section
Authorize the request section

Postman will then display your access token. Copy it to a safe location, because you’ll need it later:

Access token display
Access token display

Step 5.) Choose a LinkedIn Ads API Endpoint URL

In this section, I’ll show you how to browse the LinkedIn Ads API documentation to find an API endpoint URL that retrieves the specific information you need from your LinkedIn account. If you already know your API URL, or you want to use the same example URL as us, just skip to Step 6.

First, open the LinkedIn Ads API documentation page: https://docs.microsoft.com/en-us/linkedin/marketing/

The menu on the left contains 5 main sections: Overview, Development, API Access, Integrations and Use Cases.

LinkedIn Ads API endpoints documentation
LinkedIn Ads API endpoints documentation

The available endpoints for this API are in the last two sections: Integrations and Use Cases.

If we expand these sections, a list of categories will be displayed for each one of them:

Integrations and Use Cases section
Integrations and Use Cases section

For instance, if we click the Campaign Management category, it will expand and other subcategories will be displayed. In this subcategory we click Account Structure and then Accounts. The endpoints from Accounts subcategory will be displayed on the main section of the page. Scroll down until you find the one you need.

In this case we chose the Fetch Ad Account endpoint.

The documentation for this endpoint contains a short description of the endpoint’s purpose, the HTTP method and URL, and a sample response:

Fetch Ad Account endpoint documentation
Fetch Ad Account endpoint documentation

All API calls for LinkedIn Ads should be made to the https://api.linkedin.com/v2/ base domain.

Step 6.) Enter the LinkedIn Ads API request into the Apipheny add-on

Okay, we’re in the home stretch. Now go back to your Google Sheet and make sure that the Apipheny add-on is open on the “Import” tab. With the Import Tab open, enter these details into the add-on:

Method: At the top of the Apipheny sidebar, select the HTTP method (GET or POST) as required by your LinkedIn Ads API endpoint. For this example, we are using the GET method.

API URL: In Step 5, I explained how you can find the LinkedIn Ads API endpoint that you need. Now copy the complete API URL into the Apipheny add-on, where it says API URL Path (JSON / CSV), followed by any GET parameters required for your query.

For this example, we are using the Me endpoint, which identifies and retrieves the current member’s profile based on the access token. The corresponding URL for this endpoint is:

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

Headers: In the Headers section of the Apipheny add-on panel, add one row, with the following key and value:

Header
Key:
Authorization
Value:
Bearer <your_token>

<your_token> is the value of the token you obtained previously, in Step 4. There should be a literal space between Bearer and <your_token>. Do not include the brackets “<>” around your token.

LinkedIn Ads API request entered into Apipheny
LinkedIn Ads API request entered into Apipheny

Step 7.) Run the LinkedIn Ads API request in your Google Sheets

The last step is to click the Run button at the bottom of the Apipheny add-on and then your LinkedIn Ads data will be imported into your Google Sheet.

LinkedIn Ads data imported into Google Sheets
LinkedIn Ads data imported into Google Sheets

That’s it! You’ve successfully connected your LinkedIn Ads account to Google Sheets using the LinkedIn Ads API, Google Sheets API, and the Apipheny add-on.

After making a successful request to the LinkedIn Ads API, try querying a different LinkedIn Ads API endpoint, or try using one of the more advanced features in the Apipheny add-on, such as:

  • Save and schedule your LinkedIn Ads API request
  • Make a POST request to the LinkedIn Ads API (if available)
  • Use the custom =APIPHENY() function to call the LinkedIn Ads API request inside your spreadsheet
  • Create an API request by referencing the value of a cell in the API URL with three curly braces eg. {{{Sheet1!A1}}}

If you want to integrate your LinkedIn Ads data with Google Data Studio, just follow the same steps above and then connect your Google Sheet to your Google Data Studio report.

Related articles:

Related Posts