Forum Discussion

Malcolm_Murray's avatar
Malcolm_Murray
Practitioner II
2 years ago

Segmenting on a custom location field

Hi all, I've currently got a use case where I want to target a Braze canvas at customers who have previously ordered within a given radius of a specific location. We don't use Braze's SDK based location tracking, and don't need to (we don't need that granularity, and don't need real time location of customers), but do have location points that we would like to use and segment on.

The way I'd like to do this is:

  • Store the location we're interested in as custom property on the customer's profile as lat / long.
  • Use this custom to be the centre of a location radius in a segment filter. In the same way as we can do for `most recent location` as shown in this screenshot:

I can't find any reference to a location data type for custom properties. Clearly Braze is capable of doing such location based calculations, and has the concept of location - but this seems to be something that is very tightly coupled to use location tracking in the SDK, and not more arbitrary location operations.

We don't want to be tracking users as such, but do have specific relevant locations stored in our system. We'd like to be able to send these over to Braze so that we can use them in segment filters - but I can't see anywhere in the documentation whether this is possible or not. At present we are able to use connected audience filters to segment based on postcodes (using a regex), but we'd prefer to be more accurate re radius from a given point.

Any help or pointers with this would be hugely appreciated.

  • Hi DavidO, thanks for this.

    What I was trying to understand here was whether it would be possible do e.g., radius checks on specific locations without having to track users via the SDK. I've since realised that we can explicitly set the `current location` user property (https://www.braze.com/docs/user_guide/engagement_tools/locations_and_geofences/location_tracking/#hard-setting-the-default-location-attribute). So, although this isn't a custom property it would probably satisfy what I'm trying to do.

    However, my next blocker is how to trigger this dynamically. E.g, I'd want to set the radius to include users for to be a dynamic property, different for each invocation of the canvas (I'm triggering these via API call). I think the best bet here would be using connected audience filters, but I can't see from the Connected Audience Filter docs (https://www.braze.com/docs/api/objects_filters/connected_audience/) whether it's possible to trigger a condition something like "Most recent location must be within a circle of X Miles" etc. Seems like this might be missing from connected audience filters... or I've not worked out how to do it yet.

  • DavidO's avatar
    DavidO
    Strategist II

    Hi Malcolm_Murray 

    If I am understanding this correctly, you have latitude and longitude coordinates stored in your database and you'd like to pass these to Braze and segment using these? 

    You could pass latitude and longitude over and store each of them in their own custom attribute and potentially segment using these. For example (ignore the export/projects, that is all I had stored as numbers):

    The limitation you might be running into is that although Braze can use location, it is not an available data type to store as an attribute.

    You could take you latitude and longitude coordinates and convert them to decimals which could then be stored as a number. There is an online converter for this below but I have also posted a Stackoverflow post about how to code this with Javascript which might help you automate the process:

    https://www.fcc.gov/media/radio/dms-decimal
    javascript - Converting latitude and longitude to decimal values - Stack Overflow

    If I have totally missed your question, this was a great learning and problem to solve for me, so thank you. 😆

  • bob's avatar
    bob
    Specialist

    Malcolm_Murray - as it looks like you've already found setting the current location manually would work - although having a location type for custom attributes would be really helpful.

    How is that radius going to change as you use it? Per user? How deterministic is it? or not at all?

    Sounds like a fun project though. Would be happy to have a look at it if you could use extra eyes/brains.

    • Malcolm_Murray's avatar
      Malcolm_Murray
      Practitioner II

      The radius will change per canvas run. Basically for each run of the canvas I want to segment on users who have last ordered from a given point which is inside a radius from another point. So, although I can now set a location field for users, I can't figure out how to use this in a dynamic way.

      I use connected audience filters via the API to handle dynamic segmentation. Connected audience filters seem to cover most data type and allow us to create filters on most of the data types handled by Braze.. except for location. Braze must be able to do this behind the scenes, but the question is how do we do this dynamically?

      I can now do it via the UI. But that would mean (for us) creating a new canvas every time we want to send to customers for a different central point. This needs to be dynamic for us as it's going to be triggered in an automated way daily with different criteria.

      • bob's avatar
        bob
        Specialist

        100% agree that you shouldn't have a new canvas every time.

        Speculation:

        I'm still wondering if there's another way of thinking about this. I don't know what the underlying requirement is, but I'd be wondering if I could turn the problem on it's head and turn this into a personalisation challenge instead - and maybe thinking closer to realtime than a daily batch.

        So you'd send to 'all' (obviously not all, you'd likely want to rate limit) users that have done a thing at location X which is within Y distance of location Z - for all values of X and Z rather than just one at a time.

        Though, I guess you still need to calculate Y and depending on how many location Z's you have, that's perhaps not trivial to do on the fly.

        You could use a connected content call to an API endpoint to determine distance, but it would be good to not have to do that for lots of Zs.

        (still speculating)

        How many locations do you have? Could you pre-calculate all the distances?

        I'm also wondering if you could contain some of this 'pre' logic in a campaign that then triggers the canvas using a webhook with the variables it needs populated.

        (end speculation for now)