0

Events are sent twice to mixpanel

Hello,

we are currently experimenting with mixpanel through segment.io in our android app. It appears that every event shows twice in mixpanel. The property "Mixpanel Library" is "android" for one of the tracking events and "Segment: analytics-android" for the other. We use the mixpanel integration library and can see in the logs, that apparently one event is dispatched by the mixpanel library. Also there is only one event showing up in the debugger in segment.io. So it appears that the segment.io is forwarding the event to mixpanel although the app is already sending it through the integrated library.

Is there anything we can do stop this from happening? 

19replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • Howdy,

    If you bundled our Android SDK,you won't need to select the integration by passing through:

    {integration{Mixpanel:true}};

    We have lightened the core Analytics SDK to contain only Segment's library, so you will add Segment's Analytics pod to your podfile, and any subsequent tool's pod as you see fit.

    Since you are requiring each additional tool as a dependency, we want to be sure we don't send your data twice to these end tools. So it is expected that you will see the

    {Mixpanel: false} 

    flag in the debugger, which indicates that the request was sent directly from the device (via the Mixpanel pod). The false is telling the Segment servers not to send that request a 2nd time.

    Hope this helps!

    Reply Upvote
  • Yes, one good way to make it easier for us to debug is paste here a full raw payload from the Segment debugger that is an example event that is double counting inside Mixpanel.

    My guess is that you might be manually setting the integrations object to have `Mixpanel: true` as Ladan noted.

    If you are NOT bundling the Mixpanel SDK, then this would be a different issue so let us know!

    Reply Upvote
  • Hi. I think you are right in that the mixpanel flag should be false and is true. This is the integrations part of the message in the debugger.

    "integrations": {
      "All": true,
      "Mixpanel": true,
      "Segment.io": true
    }

    I tried to get it deactivated but nothing I do seems to change these parameters. You said that we might be setting the integrations object to have "Mixpanel: true" manually, but right now I can't find a way to do this. My understanding is, that the integration should be automatically set to false as soon as we use the bundled integration.

    This is how we initialize the Analytics object. After that we just call the track,identify,alias methods without any further configuration. 

    segmentIo = new Analytics
        .Builder(context, appToken)
        .use(MixpanelIntegration.FACTORY)
        .logLevel(Analytics.LogLevel.VERBOSE)
        .build();

    Our dependencies are 

    compile 'com.segment.analytics.android:analytics:4.0.4'
    compile 'com.segment.analytics.android.integrations:mixpanel:1.0.0'
    Reply Upvote
  • Hey there,

    We would need to see some logs to help us figure out why that integrations object is changing. I'll create a ticket for this issue and we will get in touch with you privately and post the updated solution here!

    Reply Upvote
  • Hello,

    I have the same issue here, on Android, duplicated events are sent to mixpanel! Via directly to Mixpanel and via Segment->Mixpanel.

    It sends duplicated eventes, If setup Segment like this:

    Analytics analytics = new Analytics.Builder(context, Constants.SEGMENT_WRITE_KEY)
            .use(MixpanelIntegration.FACTORY)
            .build();

    If I remove

            .use(MixpanelIntegration.FACTORY)

    It works fine, only send once.

    But... in order to configure PushNotifications, I need that Mixpanel Integration... in order to call this (.onIntegrationReady)

    Analytics.with(context).onIntegrationReady("Mixpanel", new Analytics.Callback() {
        @Override
        public void onReady(Object instance) {
            MixpanelAPI mixpanel = ((MixpanelAPI) instance);
            MixpanelAPI.People people = mixpanel.getPeople();
            people.identify(user.email);
            people.initPushHandling(Constants.SENDER_ID);
        }
    });

    Is there any fix for that ?

    Thank you

    Reply Upvote
  • Filipe, you should be able to use the factory. Are you using ios library version 3.0.0 - 3.0.3? I believe this is a bug that's been fixed in the newest 3.0.7.

    I'd confirm your podfile to make sure you are using our latest ios library!

    Reply Upvote
  • The issue it's on Android. There's no Podfile.

    The only thing I can show you, is what I have my Gradle file:

    compile 'com.segment.analytics.android:analytics:4.+'
    compile 'com.segment.analytics.android.integrations:mixpanel:+'

    Is there any update? On the Android library ? 

    Reply Upvote
  • Oh! my mistake. Can you check your debugger and open an any of the events coming in. Do you see a top level integrations object? You should see Mixpanel: false if it was bundled correct. The false denotes that our servers should not send that event again.

    So if anywhere in your code you are setting that object to Mixpanel: true then you want to make sure you are not doing that.

    Reply Upvote
  • Hello,

    I'm not passing Mixpanel: true anywhere in my code... is there anyway that I can put explicit Mixpanel: false?

    Thank you

    Reply Upvote
  • Hmm are all events being duplicated? There's really no way for this to happen unless that integrations object is setting Mixpanel: true...

    Are you absolutely positive that nothing might be doing this? Also, you don't have Mixpanel SDK natively installed outside of the Segment setup right?

    Reply Upvote
  • Filipe - can you share some more details?

    1. The exact event name that is being duplicated.

    2. The exact line of code where you call `analytics.track`.

    Reply Upvote
  • To clarify, by question 2 I meant the exact line of code where you call `analytics.track` for the event that you are seeing a duplicate.

    Reply Upvote
  • Well,

    If I put   

            .use(MixpanelIntegration.FACTORY)

    All events are sent duplicated.

    If I don't put 

            .use(MixpanelIntegration.FACTORY)

    It doesn't callback onIntegrationReady.. then I can't use 

    Analytics.with(context).onIntegrationReady("Mixpanel", new Analytics.Callback() {
    @Override
    public void onReady(Object instance) {
    MixpanelAPI mixpanel = ((MixpanelAPI) instance);
    
    MixpanelAPI.People people = mixpanel.getPeople();
    
    people.initPushHandling(Constants.SENDER_ID);
    
     }
    });

    .... So the question is:

    How can I activate Mixpanel Android PushNotifications without using 

            .use(MixpanelIntegration.FACTORY)

    Thank you

    Reply Upvote
  • Hey Filipe,

    I am interested in seeing your tracking code - the exact line of code where you call `analytics.track` for the event you are seeing the duplicate. Not the push handling code (which doesn't send an event via Segment).

    Reply Upvote
  • Sure,

    public static void trackTapLoginButton(Context context, String method) {
        Properties properties = new Properties().putValue(kKeyMethod, method);
        Analytics.with(context).track(kDidTapLoginButton, properties);
    }
    
    public static void trackTapSignupButton(Context context) {
        Analytics.with(context).track(kDidTapSignupButton, null);
    }

    Those are 2 of All the events I track, that are duplicated.

    Thank you

    Reply Upvote
  • Finally, 

    I solved my problem, with defaultOptions... 

    Options defaultOptions = new Options().setIntegration("Mixpanel", false);
    // Create an analytics client with the given context and Segment write key.
    Analytics analytics = new Analytics.Builder(context, Constants.SEGMENT_WRITE_KEY)
            .use(MixpanelIntegration.FACTORY).defaultOptions(defaultOptions)
            .build();

    That was all I was asking...

    Like that I can setup push notifications without duplicated events.

    Reply Upvote
  • Could you please paste in here precisely how to solve this problem with SWIFT on iOS? We have had this problem all year with Mixpanel and the duplicated events have screwed up our analytics and doubled our charges from Mixpanel, unfortunately! 

    This is our current setup code:

            let config = SEGAnalyticsConfiguration(writeKey: CONST("SEGMENT_KEY"))
    
            config.use(SEGFlurryIntegrationFactory())               // use Flurry natively
    
            config.use(SEGMixpanelIntegrationFactory())               // use Mixpanel natively
    
            // currently broken - awaiting Google/Cocoapod fix:
    
            config.use(SEGGoogleAnalyticsIntegrationFactory())   // use Google Analytics natively
    
            SEGAnalytics.setupWithConfiguration(config)

    How do we set the options to turn off the server-side Mixpanel integration?

    Reply Upvote
  • We're having this same issue with Segment-Mixpanel 1.2.0 and Mixpanel 3.2.6 on iOS. We tried disabling the Mixpanel destination for iOS data in the Segment Dashboard for our app but this has no apparent effect and we're still seeing duplicate events in Mixpanel. Is there some way to disable the duplication behaviour in the iOS client?

    Reply Upvote 1
  • Hi Jim,

     

    Would you mind creating a support ticket with us so we can help you directly? The link to do so it here. I'd be interested to check on some specifics regarding your Mixpanel authentication and it would be better to do that in an email thread.

     

    I look forward to helping you figure this out!

     

    Best,
    Spencer
    Success Engineer | Segment

    Reply Upvote
reply to topic