GetPostAnalytics icon
Script icon
Process icon
DiscordIncomingWebhook icon
Schedule icon

LinkedIn Analytics to Warehouse-Ready JSONL

Land LinkedIn post analytics in your warehouse with Kestra. Fetch reactions, reshape to newline-delimited JSON, and get a Discord note per export.

Categories
Business

Social metrics belong next to the rest of the marketing data, not in screenshots. This blueprint fetches reaction analytics for a list of LinkedIn posts with io.kestra.plugin.linkedin.GetPostAnalytics, then a small Python task reshapes the posts output into a newline-delimited JSON file, one record per post, stamped with the fetch time. The JSONL lands in Kestra's internal storage as an output file, the format every warehouse loader ingests without ceremony, and Discord gets a note with the record and reaction counts.

How it works

  1. fetch_analytics (io.kestra.plugin.linkedin.GetPostAnalytics) pulls reaction data for every URN in the activity_urns input. Outputs include the per-post posts array plus the totalPosts and totalReactions scalars.
  2. reshape (io.kestra.plugin.scripts.python.Script on the Process task runner) receives the array through inputFiles as posts.json, writes one JSON object per line to analytics.jsonl with a _fetched_at timestamp on each record, and emits the record count through Kestra's output protocol.
  3. The JSONL file is exposed as {{ outputs.reshape.outputFiles['analytics.jsonl'] }} for any downstream loader.
  4. notify posts the scalar counts to Discord, and the errors block sends a distinct alert when the fetch or reshape fails.
  5. A disabled-by-default Schedule trigger refreshes the export daily at 05:00.

What you get

  • LinkedIn engagement data as a warehouse-ready JSONL file instead of numbers trapped in a UI.
  • A _fetched_at stamp on every record, so repeated loads become a history of engagement over time.
  • The record count as a scalar output, usable for load validation or alert thresholds.
  • A reshape step that treats each post record opaquely, so new fields returned by the API flow through without code changes.

Who it's for

  • Marketing analytics engineers joining social engagement with campaign spend in the warehouse.
  • Data teams asked for a LinkedIn dashboard who want the data in SQL first.
  • Anyone building engagement-over-time reporting that the LinkedIn UI does not offer.

Why orchestrate this with Kestra

An export like this needs credentials, a schedule, somewhere durable to put the file, and a signal when it breaks. Kestra provides all four, and the output file URI makes the handoff to a loader a one-line reference instead of a shared filesystem.

Prerequisites

  • A LinkedIn Developer application and a valid OAuth2 access token with permission to read reactions.
  • Python 3 available on the Kestra host, the reshape uses only the standard library on the Process task runner.
  • A Discord incoming webhook for export notes and failure alerts.

Secrets

  • LINKEDIN_ACCESS_TOKEN: OAuth2 access token sent as Bearer auth for LinkedIn REST API calls.
  • DISCORD_WEBHOOK_URL: Discord incoming webhook URL.

Quick start

  1. Add the two secrets to your Kestra namespace.
  2. Replace the default activity_urns values with URNs of your own posts.
  3. Execute the flow, download analytics.jsonl from the execution's Outputs tab, and check one JSON object per post.
  4. Set disabled: false on the daily trigger.

How to extend

  • Load the JSONL into DuckDB with io.kestra.plugin.jdbc.duckdb.Query using read_json_auto over the output file, as shown in the dlt and DuckDB blueprints in this catalog.
  • Swap the landing zone, upload the file to S3, GCS, or Azure Blob with the matching plugin task and let your warehouse ingest from object storage.
  • Point a dlt pipeline at the file for schema inference and merge semantics, as shown in the dlt REST API to DuckDB blueprint.
  • Chain the LinkedIn token refresh blueprint before the fetch so the export always runs on a fresh token.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.