Avatar photo

IP Anonymization for Geo Enrichment

Back in May, we detailed our accomplishments in terms of keeping your data GDPR compliant. Part of our progress included a powerful internal toolset which enables us to fulfill your data removal requests and this toolset works well for cleaning up data already persisted at Keen. But we believe that it’s better to prevent than to cure, and we asked ourselves what could we do to facilitate the use of our API while staying compliant with GDPR.

One valuable feature of the Keen Stream API is IP to Geo enrichment. This helps enrich your events to include geolocation data for your analysis and creation of map-based data visualizations. If you send Keen an IP address with the IP to Geo enrichment enabled, we can help give you more detailed geo data for analysis, like city, state/province, country, and more.

Given an event containing an IP address, you can define an addon to convert the IP address to a location. The IP address, however, stays in the event body. To activate the enrichment, include the keen.addons object in your data model as seen below:

Input event

{
  "ip_address": "${keen.ip}",
  "keen": {
    "addons": [{
      "name": "keen:ip_to_geo",
      "input": {
        "ip": "ip_address"
      },
      "output": "ip_geo_info"
    }]
  }
}

Output event

{
  "ip_address": "192.168.0.1",
  "ip_geo_info": {
    "city": "San Francisco",
    "province": "California",
    "country": "United States",
    "country_code": "US",
    "continent": "North America",
    "postal_code": "94122",
    "coordinates": [-122.42005, 37.77479]
  },
  "keen": {
    "created_at": "2012-12-14T20:24:01.123Z",
    "timestamp": "2012-12-14T20:24:01.123Z",
    "id": "asd9fadifjaqw9asdfasdf939"
  }
}

This is a powerful enrichment, however, IP addresses are considered personal information according to GDPR terms. Storing such information requires user consent and could also be subject to “right to be forgotten” requests. As such, it’s desirable to have the IP removed from the event just after being persisted. Up until now, it was only possible to remove the property holding the IP address using the Delete API or have us remove it for you. Either way, it was a burdensome process, which wasted your time and resources.

Introducing IP Anonymization

We’ve made changes to our public API which enable you to use our enrichment functionality while maintaining GDPR compliance. We’ve extended the `ip_to_geo` addon syntax to enable the use case where the field holding the IP address is removed after the IP to Geo enrichment takes place. Furthermore, this change is backward compatible so it won’t break your existing code.

To enable the feature just add the remove_if_property key to the input map with value true. After the IP to Geo processing takes place, the source property is removed.

Input event

{
  "ip_address": "${keen.ip}",
  "keen": {
    "addons": [{
      "name": "keen:ip_to_geo",
      "input": {
        "ip": "ip_address",
        "remove_ip_property": true
      },
      "output": "ip_geo_info"
    }]
  }
}

Output event

{
  "ip_geo_info": {
    "city": "San Francisco",
    "province": "California",
    "country": "United States",
    "country_code": "US",
    "continent": "North America",
    "postal_code": "94122",
    "coordinates": [-122.42005, 37.77479]
  },
  "keen": {
    "created_at": "2012-12-14T20:24:01.123Z",
    "timestamp": "2012-12-14T20:24:01.123Z",
    "id": "asd9fadifjaqw9asdfasdf939"
  }
}

Given that storing your customer IP addresses requires consent and imposes some legal requirements regarding data management, if it’s the location that matters in your event and not the IP address then this new feature of the ip_to_geo addon is your answer. It gives you an easy, time-saving way of maintaining your data GDPR compliant as you no longer need to manually remove it from events. Try it out and let us know what you think!