Integrating Analytics in a Figma Plugin – Quick Guide


The current best solution is Mixpanel in my opinion. Integrating Mixpanel into a Figma plugin opens up a world of possibilities for analyzing user behavior and tracking valuable data.

So, welcome everyone, it’s a quick guide to setup mixpanel with figma plugins.

The Problem

Figma plugins run inside an iframe, hence have some limitations.

Original Mixpanel client will NOT work in Figma plugins UI because it uses some features like cookies, which aren’t accessible to the plugin ui.

The Solution

Using a patched version of mixpanel client file will help.

  1. Install the package npm i mixpanel-figma
  2. In your UI file, import the package. Please note that you have to use mixpanel in the UI file only, using it in the core plugin files will result in some errors. Error example
  3. Preferably, create a new file, analytics.ts and form a class with all useful methods.
import * as mixpanel from 'mixpanel-figma'

class Analytics {
    constructor() {
            mixpanel.init("", {
                disable_cookie: true, //IMP
                disable_persistence: true, //IMP
            console.log("Mixpanel initialized");
        } catch(e){
            console.log("Mixpanel failed to initialize");

    track(event: string, properties: object) {
            mixpanel.track(event, properties);
            console.log("Mixpanel event tracked");
        } catch(e){
            console.log("Mixpanel failed to track event");

    identify(id: string) {  // Unique user id (since no persistence)
            console.log("Mixpanel identified");
        } catch(e){
            console.log("Mixpanel failed to identify");

export default Analytics;

Create a class instance and call methods where ever you need to add tracking.

Hope you found this useful. I spent some time figuring all this out, so summarized it in a short article, this might help other people out there!

Thanks to okotoki for the plugin compatible file, do checkout their GitHub for more details.

See you guys soon.
My Twitter

Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post

UIUC MCS – CS 513 Review – Theory and Practice of Data Cleaning

Next Post

Open-source Fine-Tuning on Codebase with Refact

Related Posts