How to pull data from LinkedIn Ads into Google Sheets

LinkedIn Ads are paid advertisements on LinkedIn. We can use the LinkedIn API to import campaign 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
  6. Enter the LinkedIn Ads API Request into Apipheny
  7. Run the LinkedIn Ads API request

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

Apipheny is an API connector for Google Sheets. You can use Apipheny to connect your Google Sheets to unlimited API data sources, make unlimited API requests, and more. There is a 30 day free trial included.

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

2.) After you’ve installed Apipheny, open a Google Sheet and then click on the Extensions dropdown in the menu at the top.

In the dropdown list you should see Apipheny. Click Apipheny then click Import API to open the Apipheny sidebar in your Google Sheet.

open apipheny

Tip: you can open a new Google Sheet by entering this URL in your browser: sheet.new

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 an endpoint

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 your 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

Replace your_token with the value of the token you obtained previously, in Step 4. There should be a literal space between Bearer and your_token.

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

Step 7.) Run the LinkedIn Ads API request

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.


API Tutorials



API Knowledge

What is an API?
What is an API URL?
What are parameters?
What is an endpoint?
What is an API key/token?
What is basic authentication?
What are headers?
What is a GET request?
What is a POST request?