Mixpanel
The Mixpanel integration allows you to fetch Mixpanel’s events and display them at a record level into Forest.
SQL
Mongodb
Rails
To benefit from Mixpanel integration, you need to add the package mixpanel-data-export before going further.
Then, add the following code to your app.js file. In our example we will map the customers.email with the data coming from Mixpanel. You may replace by your own relevant collection(s).
By default, Mixpanel is sending the following fields: id, event, date, city, region, country, timezone, os, osVersion, browser, browserVersion. If you want to add other fields from Mixpanel, you have to add them in customProperties:
middlewares/forestadmin.js
1
...
2
const { objectMapping, connections } = require('../models');
3
4
module.exports = function (app) {
5
app.use(Liana.init({
6
configDir: path.join(__dirname, '../forest'),
7
envSecret: process.env.FOREST_ENV_SECRET,
8
authSecret: process.env.FOREST_AUTH_SECRET,
9
objectMapping,
10
connections,
11
integrations: {
12
mixpanel: {
13
apiKey: process.env.MIXPANEL_API_KEY,
14
apiSecret: process.env.MIXPANEL_SECRET_KEY,
15
mapping: ['customers.email'],
16
customProperties: ['Campaign Source', 'plan', 'tutorial complete'],
17
mixpanel: require('mixpanel-data-export')
18
},
19
},
20
}));
21
22
console.log(chalk.cyan('Your admin panel is available here: https://app.forestadmin.com/projects'));
23
};
Copied!
To benefit from Mixpanel integration, you need to add the package mixpanel-data-export before going further.
Then, add the following code to your app.js file. In our example we will map the customers.email with the data coming from Mixpanel. You may replace by your own relevant collection(s).
By default, Mixpanel is sending the following fields: id, event, date, city, region, country, timezone, os, osVersion, browser, browserVersion. If you want to add other fields from Mixpanel, you have to add them in customProperties:
middlewares/forestadmin.js
1
...
2
const { objectMapping, connections } = require('../models');
3
4
module.exports = function (app) {
5
app.use(Liana.init({
6
configDir: path.join(__dirname, '../forest'),
7
envSecret: process.env.FOREST_ENV_SECRET,
8
authSecret: process.env.FOREST_AUTH_SECRET,
9
objectMapping,
10
connections,
11
integrations: {
12
mixpanel: {
13
apiKey: process.env.MIXPANEL_API_KEY,
14
apiSecret: process.env.MIXPANEL_SECRET_KEY,
15
mapping: ['customers.email'],
16
customProperties: ['Campaign Source', 'plan', 'tutorial complete'],
17
mixpanel: require('mixpanel-data-export')
18
},
19
},
20
}));
21
22
console.log(chalk.cyan('Your admin panel is available here: https://app.forestadmin.com/projects'));
23
};
Copied!
To benefit from Mixpanel integration, you need to add the gem 'mixpanel_client' to your Gemfile.
Then, add the following code to your initializer. In our example we will map the Customer.email with the data coming from Mixpanel. You may replace by your own relevant collection(s).
By default, Mixpanel is sending the following fields: id, event, date, city, region, country, timezone, os, osVersion, browser, browserVersion. If you want to add other fields from Mixpanel, you have to add them in customProperties:
/config/initializers/forest_liana.rb
1
ForestLiana.env_secret = Rails.application.secrets.forest_env_secret
2
ForestLiana.auth_secret = Rails.application.secrets.forest_auth_secret
3
4
ForestLiana.integrations = {
5
mixpanel: {
6
api_key: 'YOUR MIXPANEL API KEY',
7
api_secret: 'YOUR MIXPANEL SECRET KEY',
8
mapping: ['Customer.email'],
9
custom_properties: ['Campaign Source', 'plan', 'tutorial complete'],
10
}
11
}
Copied!
You will then be able to see the Mixpanel events on a record, a Customer in our example.
You'll need to install the Mixpanel Data Export package to run the Mixpanel integration
Last modified 3mo ago
Copy link