What can Segment do?
The engineers at OwlEats are already using Segment as their CDP to instrument their mobile apps and learn about customer behavior. Now their goal is to enrich customer data with location so they can use their existing marketing channels (push, email, SMS) to offer location-based coupons.
Segment offers multiple approaches to enrich customer data, i.e. augment data with additional user context to make it more valuable and capable of generating more insight and engagement.
Specifically, they have the options of either:
-
Capturing and adding location data directly via mobile hardware, before it leaves the source
-
Using a reverse-lookup to translate IP Address into location data
-
Using RETL (Reverse ETL) to import user location data from OwlEats databases
Out of these three options, the first makes the most sense. OwlEats already requires its end-users to turn on location access to use the app, all they need to do is capture it and add it to each event.
Passive Location Enrichment with Mobile Plugins
Now that they’ve decided on the approach of collecting location directly from the phone, it’s important that they do this passively.
Passive enrichment means that the location Plugin should not have to pester the user with any sort of popup or permission. The app user experience itself should be responsible for requesting the user its access to Location services as part of the onboarding experience. The location Plugin they’re going to write works because users have already consented to sharing their location with OwlEats.
The Segment Plugin architecture allows developers to intercept all generated events and transform them via a single code snippet, so that we can easily enrich all events before they leave the system.
The OwlEats mobile apps are already instrumented with Analytics-Swift & Analytics-Kotlin (since these are backward compatible with my legacy codebases, have significantly improved performance, and make extensibility a breeze), so they can just get started on their Plugin!
Step 1: Define a new plugin
Write the below plugin in Kotlin for Android, (and separately in Swift for my iOS app)