Using Location Macros
A Location Macro returns Location Object data when used in an experience.
Location Object
Format
Location = { "coords": { "latitude":<latitude>, "longitude":<longitude> }, "timestamp":<13-digit unix timestamp (milliseconds)> }
Example
Location = { "coords": { "latitude":52.526821, "longitude":13.368511 }, "timestamp":1544555347000 }
But what can you do with this information? Let's apply the Location:distance function.
Format
{{ Location:distance( <Location_1>*,<Location_2>*, {} ) || "" }} *Set Location_1 as the user's current location (see Location:get or Location:watch macros). Set Location_2 as the location you want to capture the distance from (see Location:new macro).
Example
{{ Location:distance( {{ Location:get( "geo_slow", {} ) || "" }},{{ Location:new( 52.520007,13.404954, {} ) || "" }} ) || "" }} → Returns the User's distance from their current location to Berlin in meters.
When is this useful? For example, say you are releasing a product throughout Europe. Using the Advanced Event Wrapper with the Location Macros as a value, you can make the experience different if the user is within or outside of the set distance.
The Advanced Event Type allows you to set two values against each other. See below!
Advanced Event Wrapper
Value One: {{ Location:distance( Location:watch( "geo_fast",1, {} ) || "",Location:new( 52.520007, 13.404954, {} ) || "" ) || "" < 100 }} Value Two: True Condition: =
Reference:
Location Macros
Category | Field | Keyword | Notes |
---|---|---|---|
Location | User's Location on Page Load | {{ Location:get( "geo_slow", {} ) || "" }} {{ Location:get( "geo_fast", {} ) || "" }} | Returns Location Object |
Location | User's Continuous Location | {{ Location:watch( "geo_slow",<time in seconds>, {} ) || "" }} {{ Location:watch( "geo_fast",<time in seconds>, {} ) || "" }} | |
Location | Used as Reference in Distance Function | {{ Location:new( <Latitude>,<Longitude>, {} ) || "" }} | |
Location | User's Distance from Location_1 to Location_2 | {{ Location:distance( <Location_1>,<Location_2> ) || "" }} | |
Location | User's Timestamp on Page Load User's Latitude on Page Load User's Longitude on Page Load | {{ Location:current_location:timestamp }} {{ Location:current_location:coords:latitude }} {{ Location:current_location:coords:longitude }} |