Search code examples
iosfacebookidfafacebook-analyticssegment-analytics

How to send advertiserId to Segment-Analytics if iAD is deprecated


I'm trying to integrate Facebook App Events through Segments.

From Segment Integration Docs:

You will have to be sure that the IDFA is working within your app, which involves adding the iAD framework.

Once you have added this, you will start to see the context.device.advertiserId populate and the context.device.adTrackingEnabled flag set to true.

But, iAD was deprecated!

From Apple documentation:

iAd Framework
On your next regular app update or submission, you should remove the deprecated iAd framework and connection.

When I open the debugger in Segment, the values are not there:

"context": {
    "device": {
      "id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
      "manufacturer": "Apple",
      "model": "x86_64",
      "type": "ios"
    },
}

When submitting to the AppStore, I'm flagging YES to IDFA as a Segment requirement. So I can imagine that somehow it's connected.

Someone knows how to send advertiserId and adTrackingEnabled = true to Segment?


Solution

  • I solved the problem with this two lines of code:

    import AdSupport
    
    ASIdentifierManager.sharedManager().advertisingTrackingEnabled
    

    Only using this two lines, Segment-Analytics is able to send the data to their server.

    "device": {
      "adTrackingEnabled": true,
      "advertisingId": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
      "id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
      "manufacturer": "Apple",
      "model": "x86_64",
      "type": "ios"
    },