segmentio / analytics-ios

The hassle-free way to integrate analytics into any iOS application.
https://segment.com/libraries/ios
MIT License
402 stars 334 forks source link

Distinct ID 00000000-0000-0000-0000-000000000000 in Mixpanel #796

Closed IsaiahJTurner closed 6 years ago

IsaiahJTurner commented 6 years ago

I am using Mixpanel + Analytics iOS with segment and am seeing lots of users in Mixpanel with the distinct id 00000000-0000-0000-0000-000000000000. If you search this project for "00000000-0000-0000-0000-000000000000" you will find no results which makes me believe that IDFA tracking disabled is not being handled. Please see https://github.com/BranchMetrics/ios-branch-deep-linking/blob/b2cd3c456e96bfb4981fbcfac5d5ad7f41bba0a3/Branch-SDK/Branch-SDK/BNCSystemObserver.m#L64 for an example of how Branch handles this scenario.

f2prateek commented 6 years ago

We use the advertising ID as is (e.g. 000...), you should rely on the field adTrackingEnabled to see whether the value should be used or not.

f2prateek commented 6 years ago

Code here https://github.com/segmentio/analytics-ios/blob/7331756df97c0417af5038bbb08ba7b4b3a0202b/Analytics/Classes/Internal/SEGSegmentIntegration.m#L169-L175

IsaiahJTurner commented 6 years ago

@f2prateek Can you please reopen this? I'm aware you use the advertising ID as is and that is why I created this issue. Creating erroneously attributed data is an issue.

The current default behavior of analytics-ios is to use an ID to distinguish users that is not actually unique. This is likely creating bad data in hundreds of Segment accounts. Furthermore, your response provided no value on how to actually resolve this because I am not doing anything to use the advertising ID in the first place, it's the default behavior.

There may be an argument that this is not an issue with the analytics-ios project but rather with how the the Segment platform handles the advertisingId but it should not be a Segment Developer's responsibility to ensure their event data is properly attributed to a unique user with the default settings. However, I believe there is a strong argument that for analytics-ios to be sending an advertiserId when no such valid advertiserId is available is the incorrect approach.

A decent fix for this would be to modify the line in the code snippet you sent me to something more like this: if (self.configuration.enableAdvertisingTracking && GetAdTrackingEnabled() == true) because if ad tracking is not enabled, there is no advertising ID.

@ivolo @fathyb tagging a few other contributors who might take such a major oversight more seriously.

IsaiahJTurner commented 6 years ago

I also opened this ticket to help track a potential backend resolution to this: https://segment.zendesk.com/hc/requests/160806

f2prateek commented 6 years ago

If the current default behaviour does not work for you, here's how you can change it:

  1. Disable automatic advertising ID collection.

    SEGAnalyticsConfiguration *configuration = [SEGAnalyticsConfiguration configurationWithWriteKey:@"YOUR_WRITE_KEY"];
    configuration.enableAdvertisingTracking = @NO;
    ...
    [SEGAnalytics setupWithConfiguration:configuration];
  2. Track the advertising ID yourself. You can do this either by sending this in your calls manually, or by using a middleware.

IsaiahJTurner commented 6 years ago

@f2prateek thanks for your response but respectfully, I'd like another engineer to take a look here. Replies like "You can do this either by sending this in your calls manually, or by using a middleware." are not helpful without code examples. Disabled IDFA collection is also not a solution as the IDFA provides valuable information. I think your teammates at Segment would agree that it's important for an analytics platform to uniquely identify users.

IsaiahJTurner commented 6 years ago

As you can see this is very common behavior. In addition to Branch metrics, Mixpanel's own library uses a different identifier when the IDFA is not available. Please see: https://github.com/mixpanel/mixpanel-swift/blob/3aea168c156eb521086587e07b501a8bccdf19c5/Mixpanel/MixpanelInstance.swift#L576

f2prateek commented 6 years ago

. Disabled IDFA collection is also not a solution as the IDFA provides valuable information.

I agree - hence I suggested if the defaults don't work for you can disable the default and customize the collection to your liking :)

uniquely identify users.

that's what the userId and anonymousId are for. You can read more about identities in Segment at https://segment.com/docs/spec/identify/#identities

IsaiahJTurner commented 6 years ago

@f2prateek OK (last message) so just to confirm this is the expected behavior:

  1. Customer creates Segment account.
  2. Customer installs analytics-ios with default settings.
  3. Customer sets up Mixpanel integration.
  4. Customer sets up an event "Application Opened"
  5. User A (on a device with limit tracking enabled) installs and opens app.
  6. User B (on a different device with limit tracking enabled) installs and opens app app.
  7. User A and User B show up as the same user in the Mixpanel dashboard, contrary to how all other non-segment analytics platforms work.
f2prateek commented 6 years ago

It also sounds like you are specifically referring to Mixpanel here, as Mixpanel joins users based on the advertisingId. This is behaviour specific to the Mixpanel integration (we integrate with over hundreds of tools, some of whom expect the raw advertising value of 0000..), hence I don't think a fix in the library would be the right place to make this change.

The server side integration Mixpanel should be updated to not send a 0000.. advertising ID as the distinct Id. Since the code for this component is closed source, the Zendesk ticket is the right avenue to escalate this issue 👍

f2prateek commented 6 years ago

Additionally re: https://github.com/segmentio/analytics-ios/issues/796#issuecomment-435279064 ; by default the Mixpanel setting for Use Advertising ID for Distinct ID is disabled. Hence you would not see User A and User B show up as the same user until you enable the setting Use Advertising ID for Distinct ID.

IsaiahJTurner commented 6 years ago

@f2prateek I checked Mixpanel's dashboard/documentation as well as Segment's and can't find a setting called "Use Advertising ID for Distinct ID" could you direct me to where this is?

f2prateek commented 6 years ago

My mistake - it's a legacy setting that's hidden. It's still disabled by default though, so I'm not sure why it'd be enabled for you.

I'm out for the next couple of weeks and a different team manages the integrations - so I'd recommend asking via the Zendesk thread so it gets routed to the right people!

IsaiahJTurner commented 6 years ago

@f2prateek got it, very strange indeed! Apologies for my frustrations earlier. Understand you've got a lot on your plate. Really appreciate the more recent quick and helpful replies! I'm still waiting (hoping?) for a reply on Zendesk.