Send Data To Multiple Projects

You can initialize separate Mixpanel objects with different tokens to send event and property updates to separate projects.

This separation is useful when you want certain events to appear in one project and others events to appear in a different project.


Sending event data from a single website to multiple different Mixpanel projects is possible by using the JavaScript library and modifying the mixpanel.init call.

The optional library_name parameter in the mixpanel.init function allows you to specify which library to write to in all tracking calls.

For example, suppose you have project A with a token of "123abc" and project B with a token of "456def."

After your initial Project A init call (with 123abc), you could set up a second instance of the initialization like this:

mixpanel.init("456def", {}, "project_b")

You would then send any project B calls like this:

mixpanel.project_b.track("Event name") 

Any standard track calls without a specified project name would go to the initial Mixpanel project.

Read additional documentation on mixpanel.library_name.


You can create multiple instances of the Mixpanel API and switch back and forth between two projects by using the initWithToken method.

You can specify your second project token in this method.

Note that codeless events and A/B testing will always apply to the instance with sharedInstanceWithToken.

For example:

Mixpanel *master = [Mixpanel sharedInstanceWithToken:MASTER_TOKEN];

Mixpanel *publisher = [[Mixpanel alloc] initWithToken:PUBLISHER_TOKEN andFlushInterval: 60];

[master track:@"..."];

[publisher track:@"..."];


To initialize multiple instances of Mixpanel on Android, construct separate Mixpanel objects.

The codeless events and A/B testing apply to the most recent response from the decide server.

Here's an example

public class MainActivity extends AppCompatActivity {
    public MixpanelAPI mixpanel;
    public MixpanelAPI mMixpanel;

    private static final String projectToken = "TOKEN 1";
    private static final String projectToken_t = "TOKEN 2";
    private static Context context;

    protected void onCreate(Bundle savedInstanceState) {



        mixpanel = MixpanelAPI.getInstance(this, projectToken);
        mMixpanel = MixpanelAPI.getInstance(this, projectToken_t);

        try {
            JSONObject props = new JSONObject();
            props.put("Screen", "MainActivity");
            mixpanel.track("Viewed Screen", props);
            mMixpanel.track("Viewed Screen", props);
        } catch (JSONException e) {
            Log.e("MYAPP", "Unable to add properties to JSONObject", e);
Did this answer your question?



Article is closed for comments.