---
title: Integrating Apple App Store Data with Mixpanel
description: Automate the integration of Apple App Store data with Mixpanel for comprehensive app analytics and data-driven decisions. Follow our step-by-step guide for seamless setup and execution.
image: https://optiblack.com/hubfs/Contact%20Center%20LinkedIn%20Post%20(7).png
---

OPTIBLACK

- [Services](https://optiblack.com/services)
- [Customers](https://optiblack.com/customers)

[Book a strategy call](https://optiblack.com/book-a-call)

- [Services](https://optiblack.com/services)
- [Customers](https://optiblack.com/customers)

[Book a strategy call](https://optiblack.com/book-a-call)

[Information](https://optiblack.com/insights/tag/information) [Resources](https://optiblack.com/insights/tag/resources) [mixpanel](https://optiblack.com/insights/tag/mixpanel) Nov 24, 2024, 3:29:50 PM · 7 min read

# Integrating Apple App Store Data with Mixpanel

![Aswin Kumar](https://optiblack.com/hubfs/T03B5CKT6HZ-U07FHH1ESR0-561cebd6e111-512.jpeg)

Aswin Kumar

Optiblack

![](https://optiblack.com/hubfs/Contact%20Center%20LinkedIn%20Post%20(7).png)

### **Overview**

This guide provides a step-by-step process for automating the extraction, processing, and integration of app analytics data from Apple’s App Store Connect API into Mixpanel for analysis. We will go over how to set up JWT-based authentication, create and manage report requests, retrieve report segments, and finally parse and send data to Mixpanel.

 

---

 

**Prerequisites**

Before starting, make sure you have the following:

1. **Apple Developer Account** with App Store Connect API access. This includes: 
     - Access to generate API keys in **Users and Access** \> **Keys**.
     - A valid .p8 key file downloaded for JWT authentication.
2. **Mixpanel Account** for tracking and analysing app events. Obtain: 
     - Project token and secret key from the Mixpanel project settings.
3. **Node.js** installed on your machine along with these Node.js packages: 
     - jsonwebtoken for generating JWT tokens.
     - node-fetch for making HTTP requests.
     - zlib and csv-parser for handling and parsing data.
     - fs and path for file handling and directory management.
     - **mixpanel for integrating with Mixpanel’s API.**

 

---

 

### **Step-by-Step Guide**

 

### **Step 1: Establish a JWT Connection to App Store Connect**

The App Store Connect API requires JWT (JSON Web Token) authentication, which involves creating a token using a .p8 key file and additional information from your Apple Developer account.

#### **1.1 Obtain the .p8 Key File, Key ID, and Issuer ID**

In your Apple Developer account:

1. Go to **Users and Access** \> **Keys** and create a new API key. 
     - **Download the .p8 key file** and store it in your project directory.
     - **Note the Key ID** associated with the API key; you’ll need it for the JWT header.
2. To find the **Issuer ID**: 
     1. Go to **Users and Access** in your developer account, and you’ll see the **Issuer ID** listed at the top of the page.

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXfYnLmSgq5-H4donnDAUGBc6J7LxSlzG1bi5GhUb8YnBt-L_h36y9xGxPeN8W0uWD8OIJ3ljVRYG-IupSSQODeKovgwYRq0oCiO6emwhtTXymjwk6sXuqM6wC8ot9zDJpbSZDzb?key=lgY2l0yltu8RnISKovVwlVzU)

### **1.2 Configure JWT Authentication in Your Code**

To create the JWT, you’ll need the **Key ID**, **Issuer ID**, and **Private Key** from the .p8 file setup.

**Import necessary libraries**:

const fs = require('fs');

const jwt = require('jsonwebtoken');

const path = require('path');

1. **Load the private key**: 
     - The private key itself is in the .p8 file, which you’ll load into your code to sign the JWT.

const KEY\_ID = 'YOUR\_KEY\_ID'; // Found in your developer account with the API key

const ISSUER\_ID = 'YOUR\_ISSUER\_ID'; // Found in Users and Access in your developer account

const PATH\_TO\_KEY = path.join(\_\_dirname, 'AuthKey.p8');

const privateKey = fs.readFileSync(PATH\_TO\_KEY, 'utf8');

1. **Generate the JWT token** with an expiration time (usually 20 minutes):

javascript  
Copy code  
const token = jwt.sign(

{ iss: ISSUER\_ID, exp: Math.floor(Date.now() / 1000) + (20 \* 60), aud: 'appstoreconnect-v1' },

  privateKey,

{ algorithm: 'ES256', header: { alg: 'ES256', kid: KEY\_ID, typ: 'JWT' } }

);

The token variable now holds the JWT, ready for authentication with the App Store Connect API. (https://appstoreconnect.apple.com/access/integrations/api)

---

 

### **Step 2: Create a Report Request on App Store Connect**

With the JWT token, we can create a report request to start retrieving app metrics. Apple allows reports to be configured as **ONGOING** (for continuous updates) or **ONE\_TIME\_SNAPSHOT** (for a single snapshot).

#### **2.1 Define the Request Data**

Specify the report type (ongoing or one-time) and include your app ID:

const requestData = {

  data: {

    type: 'analyticsReportRequests',

    attributes: {

      accessType: 'ONGOING', // or ONE\_TIME\_SNAPSHOT for a single snapshot

    },

    relationships: {

      app: {

        data: {

          type: 'apps',

          id: 'YOUR\_APP\_ID'

        }

      }

    }

  }

};

 

#### **2.2 Send the Request**

Make a POST request with the JWT token to initiate the report request:

async function createReportRequest() {

  const url = 'https://api.appstoreconnect.apple.com/v1/analyticsReportRequests';

  const options = {

    method: 'POST',

    headers: {

      Authorization: \`Bearer ${token}\`,

      'Content-Type': 'application/json'

    },

    body: JSON.stringify(requestData)

  };

 

  try {

    const response = await fetch(url, options);

    const data = await response.json();

    if (data.data && data.data.id) {

      console.log(\`Created report request ID: ${data.data.id}\`);

    }

  } catch (error) {

    console.error('Error creating report request:', error);

  }

}

---

 

### **Step 3: Retrieve Report Requests by Category and Name**

You can filter reports by specific categories (e.g., APP\_USAGE, APP\_STORE\_ENGAGEMENT) and by name. This helps in customising data queries based on various parameters.

async function getReportByCategory(category, name) {

  const url = \`https://api.appstoreconnect.apple.com/v1/analyticsReportRequests?filter\[category\]=${category}&filter\[name\]=${name}\`;

  const headers = {

    Authorization: \`Bearer ${token}\`,

    'Content-Type': 'application/json'

  };

 

  try {

    const response = await fetch(url, { method: 'GET', headers });

    const data = await response.json();

    console.log('Report Data:', data);

  } catch (error) {

    console.error('Error fetching report by category:', error);

  }

}

 

---

 

### **Step 4: Fetch and Process Report Instances**

After confirming the report request’s creation, retrieve specific instances of reports, which can include additional parameters to refine data by date, granularity, and other attributes.

#### **Query Parameters Available:**

- granularity: Specify the data frequency, such as DAILY, WEEKLY, MONTHLY.
- processingDate: Filter data based on a particular date. etc..

async function getReportInstances(reportRequestId) {

  const url = \`https://api.appstoreconnect.apple.com/v1/analyticsReportRequests/${reportRequestId}/instances?filter\[granularity\]=DAILY&filter\[processingDate\]=YOUR\_DATE\`;

  const headers = { Authorization: \`Bearer ${token}\`, 'Content-Type': 'application/json' };

 

  try {

    const response = await fetch(url, { method: 'GET', headers });

    const data = await response.json();

    console.log('Report Instances:', data);

  } catch (error) {

    console.error('Error fetching report instances:', error);

  }

}

---

 

### **Step 5: Fetch Segment Data**

Once the report instances are available, each instance contains segments that give specific data points. Retrieve segments by accessing the segment URL provided in the report instance data.

async function getSegmentsForInstance(instanceId) {

  const url = \`https://api.appstoreconnect.apple.com/v1/analyticsReportInstances/${instanceId}/segments\`;

  const headers = { Authorization: \`Bearer ${token}\`, 'Content-Type': 'application/json' };

 

  try {

    const response = await fetch(url, { method: 'GET', headers });

    const data = await response.json();

    const segmentUrl = data.data\[0\].attributes.url; // Get the URL for downloading data

    if (segmentUrl) {

      downloadReportData(segmentUrl);

    }

  } catch (error) {

    console.error('Error fetching segments:', error);

  }

}

---

 

### **Step 6: Download and Extract the Report Data**

After retrieving the download URL from the segment data, download and decompress the data (often in .gz format).

async function downloadReportData(url) {

  const dir = path.join(\_\_dirname, 'reports');

  const gzPath = path.join(dir, 'report.gz');

  const csvPath = path.join(dir, 'report.csv');

 

  if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });

 

  const response = await fetch(url);

  const fileStream = fs.createWriteStream(gzPath);

  response.body.pipe(fileStream);

 

  fileStream.on('finish', () =\> {

    fs.createReadStream(gzPath)

      .pipe(zlib.createGunzip())

      .pipe(fs.createWriteStream(csvPath))

      .on('finish', () =\> console.log('Report downloaded and extracted'));

  });

}

 

---

 

### **Step 7: Parse CSV and Send Data to Mixpanel**

With the CSV data available, parse it and send it to Mixpanel for tracking.

**Parse the CSV Data**:  
fs.createReadStream('report.csv')

  .pipe(csv())

  .on('data', (row) =\> {

    console.log('Parsed Row:', row);

    // Add logic to structure data for Mixpanel

  })

  .on('end', () =\> {

    console.log('CSV Parsing completed.');

  });

**Send Data to Mixpanel**: Initialize Mixpanel and send parsed data:

- Create a Mixpanel Account: 
- Visit Mixpanel (*https://mixpanel.com*). 
- Click Sign Up if you are new or Log In if you already have an account. 
- Set Up a Project 
- Click Create New Project from the Projects tab on your dashboard.
- Name your project, such as "Google Play Store Data Integration" and click Create Project. 
- Retrieve Project Token and API Secret: 
- Go to Settings \> Project Settings under your project. 
- Copy the Project Token.      ![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXfwnWL-Nkczlno4T7YYmhVRDzwcxxkB-lNgpZNe08Xx0NQFAcWsHmoH0drFfwIsn1BHzNFLR6JXAw2odghPMGoLfrediMLHN_tP0wvbrlpdIL9hQFyeVjzsIBsWokzt0Fzy7tU2sg?key=lgY2l0yltu8RnISKovVwlVzU)

- Access the API Secret under Service Accounts if not already created. 
- Store Mixpanel Credentials 

- Install Mixpanel Library: 

***npm install mixpanel ***

const mixpanel = require('mixpanel');

const mixpanelImporter = mixpanel.init('YOUR\_PROJECT\_TOKEN', {

  secret: 'YOUR\_SECRET\_KEY',

  host: 'api.mixpanel.com'

});

function sendToMixpanel(data) {

  mixpanelImporter.track('Event Name', data, (err) =\> {

    if (err) console.error('Error sending data to Mixpanel:', err);

    else console.log('Data sent to Mixpanel');

  });

}

 

### **Conclusion**

Following this guide allows you to automate the entire process of fetching, processing, and sending Apple App Store data to Mixpanel for advanced insights. With this integration, you gain a streamlined way to track app performance and make data-driven decisions.

**Refer to the Apple Store Connect API (https://developer.apple.com/documentation/appstoreconnectapi/downloading-analytics-reports) and Mixpanel API (https://developer.mixpanel.com/reference/overview) Documentation for further details.**

![Aswin Kumar](https://optiblack.com/hubfs/T03B5CKT6HZ-U07FHH1ESR0-561cebd6e111-512.jpeg)

Aswin Kumar

Tech @ Optiblack

[#Information](https://optiblack.com/insights/tag/information) [#Resources](https://optiblack.com/insights/tag/resources) [#mixpanel](https://optiblack.com/insights/tag/mixpanel)

/ Keep reading

## More from Optiblack

[![From Zero to a Multi-Region Analytics Backbone: How OptiBlack Built Scrut's Entire Data Platform](https://optiblack.com/hubfs/Optiblack%20Vishal%20Rewari%20Product%20Analytics%20(12)-3.png) Case Studies From Zero to a Multi-Region Analytics Backbone: How OptiBlack Built Scrut's Entire Data Platform](https://optiblack.com/insights/from-zero-to-a-multi-region-analytics-backbone-how-optiblack-built-scruts-entire-data-platform) [![AI in Geographic Segmentation: Key Use Cases](https://optiblack.com/hubfs/Optiblack%20Vishal%20Rewari%20Product%20Analytics%20(11)-4.png) Information AI in Geographic Segmentation: Key Use Cases](https://optiblack.com/insights/ai-geographic-segmentation-key-use-cases) [![RealBooks Selects Optiblack as Strategic Analytics Partner to Build Modern Data Stack for Real Estate Investors](https://optiblack.com/hubfs/Optiblack%20Vishal%20Rewari%20Product%20Analytics%20(11)-3.png) News RealBooks Selects Optiblack as Strategic Analytics Partner to Build Modern Data Stack for Real Estate Investors](https://optiblack.com/insights/realbooks-selects-optiblack-as-strategic-analytics-partner-to-build-modern-data-stack-for-real-estate-investors)

/ 15-minute exploration call

## Turn these insights into revenue.

We'll go through your CRM, product, and analytics data together and show you exactly where growth is leaking. No setup. No dashboards. Just signal.

[Book a strategy call →](https://optiblack.com/book-a-call)

[OPTIBLACK](https://optiblack.com/)

 US: 1309 Coffeen Ave, Suite 1200, Sheridan, WY 82801 · +1 682 297 2970 — India: 297 Designs, 74 SBK Society, Paldi, Ahmedabad 380007 · +91 9819394297

 Services

[Data services](https://optiblack.com/services) [CRM services](https://optiblack.com/services) [AI services](https://optiblack.com/services) [Book a call](https://optiblack.com/services)

 Company

[Customers](https://optiblack.com/customers) [About Us](https://optiblack.com/about-us) [Insights](https://optiblack.com/insights)

 © 2026 Optiblack · 2× Mixpanel Partner of the Year · vishal@optiblack.com

```json
{
  "@context" : "https://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Aswin Kumar",
    "url" : "https://optiblack.com/insights/author/aswin-kumar"
  },
  "dateModified" : "2025-10-20T11:16:55.880Z",
  "datePublished" : "2024-11-24T09:59:50.000Z",
  "headline" : "Integrating Apple App Store Data with Mixpanel",
  "image" : [ "https://optiblack.com/hubfs/Contact%20Center%20LinkedIn%20Post%20(7).png" ],
  "mainEntityOfPage" : {
    "@id" : "https://optiblack.com/insights/integrating-apple-app-store-data-with-mixpanel",
    "@type" : "WebPage"
  },
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "url" : "https://optiblack.com/hubfs/Group%201234.png"
    },
    "name" : "Optiblack"
  }
}
```