# Get ad analytics

GET https://services.leadconnectorhq.com/ad-publishing/linkedin/reporting

Retrieve LinkedIn Ads analytics data with configurable pivot and time grouping

## Authentication

Send `Authorization: Bearer <token>` using:

- **Sub-Account token: OAuth access token or Private Integration Token.** Scopes: `adPublishing.readonly`

## Parameters

### Header Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Version` | string | Yes | API Version |

### Query Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `locationId` | string | Yes | Location ID |
| `pivot` | string | No | Analytics pivot type |
| `groupBy` | string | No | Time granularity for analytics |
| `startDate` | string | Yes | Start date in yyyy-mm-dd format |
| `endDate` | string | Yes | End date in yyyy-mm-dd format |
| `entityUrns` | string | No | Comma-separated list of entity URNs |
| `fields` | array | No | Reporting fields. Pass as comma-separated values on the wire (e.g. ?fields=impressions,clicks). |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "HighLevel API",
    "version": "2023-02-21"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/ad-publishing/linkedin/reporting": {
      "get": {
        "summary": "Get ad analytics",
        "operationId": "getAdAnalytics",
        "description": "Retrieve LinkedIn Ads analytics data with configurable pivot and time grouping",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "2023-02-21"
              ]
            }
          },
          {
            "name": "locationId",
            "required": true,
            "in": "query",
            "description": "Location ID",
            "schema": {
              "example": "loc_abc123",
              "type": "string"
            }
          },
          {
            "name": "pivot",
            "required": false,
            "in": "query",
            "description": "Analytics pivot type",
            "schema": {
              "default": "ACCOUNT",
              "example": "ACCOUNT",
              "enum": [
                "ACCOUNT",
                "CAMPAIGN",
                "CAMPAIGN_GROUP",
                "CREATIVE"
              ],
              "type": "string"
            }
          },
          {
            "name": "groupBy",
            "required": false,
            "in": "query",
            "description": "Time granularity for analytics",
            "schema": {
              "default": "day",
              "example": "day",
              "enum": [
                "day",
                "month",
                "year"
              ],
              "type": "string"
            }
          },
          {
            "name": "startDate",
            "required": true,
            "in": "query",
            "description": "Start date in yyyy-mm-dd format",
            "schema": {
              "example": "2024-01-01",
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "required": true,
            "in": "query",
            "description": "End date in yyyy-mm-dd format",
            "schema": {
              "example": "2024-01-31",
              "type": "string"
            }
          },
          {
            "name": "entityUrns",
            "required": false,
            "in": "query",
            "description": "Comma-separated list of entity URNs",
            "schema": {
              "example": "urn:li:sponsoredCampaign:123,urn:li:sponsoredCampaign:456",
              "type": "string"
            }
          },
          {
            "name": "fields",
            "required": false,
            "in": "query",
            "description": "Reporting fields. Pass as comma-separated values on the wire (e.g. ?fields=impressions,clicks).",
            "schema": {
              "example": [
                "impressions",
                "clicks",
                "costInUsd"
              ],
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "clicks",
                  "oneClickLeads",
                  "costInLocalCurrency",
                  "impressions",
                  "costInUsd",
                  "ctr",
                  "cpc",
                  "cpm",
                  "cpl",
                  "externalWebsitePostClickConversions",
                  "conversionRate"
                ]
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Metrics grouped by the requested pivot, plus totals. Only the requested `fields` appear.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LinkedInReportingResponseDTO"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestDTO"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedDTO"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnprocessableDTO"
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerErrorDTO"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": [
              "adPublishing.readonly"
            ]
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account.",
        "type": "http"
      },
      "Agency-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency (OR) Private Integration Token of Agency.",
        "type": "http"
      },
      "Agency-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency.",
        "type": "http"
      }
    },
    "schemas": {
      "LinkedInReportingResponseDTO": {
        "type": "object",
        "properties": {
          "grouped": {
            "description": "One entry per pivot bucket",
            "example": [
              {
                "impressions": 15230,
                "clicks": 214,
                "oneClickLeads": 8,
                "externalWebsitePostClickConversions": 6,
                "ctr": 1.4,
                "cpc": 0.66,
                "cpm": 9.35,
                "cpl": 17.79,
                "conversionRate": 3.74,
                "pivotValues": [
                  "urn:li:sponsoredAccount:509444880"
                ],
                "dateStart": "2026-07-01",
                "dateEnd": "2026-07-31",
                "costInUsd": "576.049999999999648674",
                "costInLocalCurrency": "576.05000000000014868"
              }
            ],
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "impressions": {
                  "type": "number",
                  "description": "Impressions",
                  "example": 15230
                },
                "clicks": {
                  "type": "number",
                  "description": "Clicks",
                  "example": 214
                },
                "oneClickLeads": {
                  "type": "number",
                  "description": "Leads captured through a one-click lead form",
                  "example": 8
                },
                "externalWebsitePostClickConversions": {
                  "type": "number",
                  "description": "Conversions recorded on an external site after a click",
                  "example": 6
                },
                "ctr": {
                  "type": "number",
                  "description": "Click-through rate as a percentage, e.g. 1.40 means 1.40%. Null when it cannot be computed.",
                  "example": 1.4,
                  "nullable": true
                },
                "cpc": {
                  "type": "number",
                  "description": "Cost per click in the account currency. Null when it cannot be computed.",
                  "example": 0.66,
                  "nullable": true
                },
                "cpm": {
                  "type": "number",
                  "description": "Cost per thousand impressions. Null when it cannot be computed.",
                  "example": 9.35,
                  "nullable": true
                },
                "cpl": {
                  "type": "number",
                  "description": "Cost per lead. Null when it cannot be computed.",
                  "example": 17.79,
                  "nullable": true
                },
                "conversionRate": {
                  "type": "number",
                  "description": "Conversion rate as a percentage. Null when it cannot be computed.",
                  "example": 3.74,
                  "nullable": true
                },
                "pivotValues": {
                  "description": "URNs of the entity this row is pivoted on — a sponsored account, campaign group or creative depending on the request. This is not the time bucket; that is carried by `dateStart`/`dateEnd`.",
                  "example": [
                    "urn:li:sponsoredAccount:509444880"
                  ],
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "dateStart": {
                  "type": "string",
                  "description": "First day covered by the row",
                  "example": "2026-07-01"
                },
                "dateEnd": {
                  "type": "string",
                  "description": "Last day covered by the row",
                  "example": "2026-07-31"
                },
                "costInUsd": {
                  "type": "string",
                  "description": "Spend in USD. Returned as a **string** on grouped rows, unlike in `totals`, and at full source precision — e.g. `899.99999999999988713`. Parse as a decimal rather than a float.",
                  "example": "576.049999999999648674"
                },
                "costInLocalCurrency": {
                  "type": "string",
                  "description": "Spend in the account currency. Returned as a **string** on grouped rows, unlike in `totals`, and at full source precision. Parse as a decimal rather than a float.",
                  "example": "576.05000000000014868"
                }
              },
              "required": [
                "pivotValues",
                "dateStart",
                "dateEnd"
              ],
              "title": "LinkedInReportingGroupDTO"
            }
          },
          "totals": {
            "description": "Metrics summed across every bucket",
            "example": {
              "impressions": 15230,
              "clicks": 214,
              "oneClickLeads": 8,
              "externalWebsitePostClickConversions": 6,
              "ctr": 1.4,
              "cpc": 0.66,
              "cpm": 9.35,
              "cpl": 17.79,
              "conversionRate": 3.74,
              "costInUsd": 240.45,
              "costInLocalCurrency": 240.45
            },
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "impressions": {
                    "type": "number",
                    "description": "Impressions",
                    "example": 15230
                  },
                  "clicks": {
                    "type": "number",
                    "description": "Clicks",
                    "example": 214
                  },
                  "oneClickLeads": {
                    "type": "number",
                    "description": "Leads captured through a one-click lead form",
                    "example": 8
                  },
                  "externalWebsitePostClickConversions": {
                    "type": "number",
                    "description": "Conversions recorded on an external site after a click",
                    "example": 6
                  },
                  "ctr": {
                    "type": "number",
                    "description": "Click-through rate as a percentage, e.g. 1.40 means 1.40%. Null when it cannot be computed.",
                    "example": 1.4,
                    "nullable": true
                  },
                  "cpc": {
                    "type": "number",
                    "description": "Cost per click in the account currency. Null when it cannot be computed.",
                    "example": 0.66,
                    "nullable": true
                  },
                  "cpm": {
                    "type": "number",
                    "description": "Cost per thousand impressions. Null when it cannot be computed.",
                    "example": 9.35,
                    "nullable": true
                  },
                  "cpl": {
                    "type": "number",
                    "description": "Cost per lead. Null when it cannot be computed.",
                    "example": 17.79,
                    "nullable": true
                  },
                  "conversionRate": {
                    "type": "number",
                    "description": "Conversion rate as a percentage. Null when it cannot be computed.",
                    "example": 3.74,
                    "nullable": true
                  },
                  "costInUsd": {
                    "type": "number",
                    "description": "Total spend in USD. Returned as a **number** here, unlike on grouped rows.",
                    "example": 240.45
                  },
                  "costInLocalCurrency": {
                    "type": "number",
                    "description": "Total spend in the account currency. Returned as a **number** here, unlike on grouped rows.",
                    "example": 240.45
                  }
                },
                "title": "LinkedInReportingTotalsDTO"
              }
            ]
          }
        },
        "required": [
          "grouped",
          "totals"
        ],
        "title": "LinkedInReportingResponseDTO"
      },
      "BadRequestDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 400
          },
          "message": {
            "type": "string",
            "example": "Bad Request"
          }
        },
        "title": "BadRequestDTO"
      },
      "UnauthorizedDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 401
          },
          "message": {
            "type": "string",
            "example": "Invalid token: access token is invalid"
          },
          "error": {
            "type": "string",
            "example": "Unauthorized"
          }
        },
        "title": "UnauthorizedDTO"
      },
      "UnprocessableDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 422
          },
          "message": {
            "example": [
              "Unprocessable Entity"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "error": {
            "type": "string",
            "example": "Unprocessable Entity"
          }
        },
        "title": "UnprocessableDTO"
      },
      "InternalServerErrorDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "description": "HTTP status code for an unexpected server error",
            "example": 500
          },
          "message": {
            "type": "string",
            "description": "Error message describing the server failure",
            "example": "Internal Server Error"
          }
        },
        "title": "InternalServerErrorDTO"
      }
    }
  }
}
```

## Code Examples

**cURL**

```bash
curl -L -X GET 'https://services.leadconnectorhq.com/ad-publishing/linkedin/reporting?locationId=<LOCATIONID>&startDate=<STARTDATE>&endDate=<ENDDATE>' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: 2023-02-21'
```

**Node.js**

```javascript
const options = {
  method: 'GET',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: '2023-02-21'
  }
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/ad-publishing/linkedin/reporting?locationId=<LOCATIONID>&startDate=<STARTDATE>&endDate=<ENDDATE>', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/ad-publishing/linkedin/reporting"

headers = {
    "Authorization": "Bearer <TOKEN>",
    "Version": "2023-02-21"
}

params = {
    "locationId": "<LOCATIONID>",
    "startDate": "<STARTDATE>",
    "endDate": "<ENDDATE>"
}

response = requests.get(url, params=params, headers=headers)
print(response.json())
```

**PHP**

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/ad-publishing/linkedin/reporting?locationId=<LOCATIONID>&startDate=<STARTDATE>&endDate=<ENDDATE>',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: 2023-02-21',
  ],
]);

$response = curl_exec($curl);
curl_close($curl);
echo $response;
```

**Java**

```java
HttpResponse<String> response = Unirest
  .get("https://services.leadconnectorhq.com/ad-publishing/linkedin/reporting?locationId=<LOCATIONID>&startDate=<STARTDATE>&endDate=<ENDDATE>")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "2023-02-21")
  .asString();
```

**Go**

```go
package main

import (
  "fmt"
  "net/http"
  "io"
)

func main() {
  url := "https://services.leadconnectorhq.com/ad-publishing/linkedin/reporting?locationId=<LOCATIONID>&startDate=<STARTDATE>&endDate=<ENDDATE>"
  req, _ := http.NewRequest("GET", url, nil)
  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Version", "2023-02-21")

  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := io.ReadAll(res.Body)
  fmt.Println(string(body))
}
```

**Ruby**

```ruby
require 'uri'
require 'net/http'

url = URI("https://services.leadconnectorhq.com/ad-publishing/linkedin/reporting?locationId=<LOCATIONID>&startDate=<STARTDATE>&endDate=<ENDDATE>")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "2023-02-21"

response = http.request(request)
puts response.read_body
```

**PowerShell**

```powershell
$headers = @{
  "Authorization" = "Bearer <TOKEN>"
  "Version" = "2023-02-21"
}

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/ad-publishing/linkedin/reporting?locationId=<LOCATIONID>&startDate=<STARTDATE>&endDate=<ENDDATE>' -Method 'GET' -Headers $headers
$response | ConvertTo-Json
```
