What is the geolocation plugin used for?
The geolocation plugin allows you to request the user's consent to share their location and then work with this location data in Mailocator. If the user provides their location, you can launch or filter campaigns based on it, typically using a radius in kilometers in campaign filters.
Providing location cannot be enforced or bypassed. The user must give explicit consent within their browser or device.
How geolocation works in practice
After activating the Mailocator plugin:
displays a prompt to provide location,
saves location data (if available and sufficiently accurate),
makes it available for use in campaign filters (e.g., distance from a point).
If the user does not provide their location or the device cannot determine the location, Mailocator continues to work with this status and the campaign filters behave accordingly.
Default plugin behavior
If the geolocation plugin is active and has not been modified, the following default rules apply:
The location request will appear automatically on the second page of the visit.
The obtained location is stored for a maximum of 150 days (after which the request must be displayed again).
The location is considered valid if it has an accuracy of within 10 km (10,000 m).
These rules are designed to ensure that the prompt is not intrusive while providing usable data for campaign targeting.
Modifying behavior using custom JavaScript
The behavior of the geolocation plugin can be modified by inserting a configuration object into Settings → Custom code (JavaScript).
const mlGeolocationCfg = {
run: "auto",
ttl: 150,
pageNum: 2,
minAccuracy: 10000
} Meaning of individual parameters
run – how to start the prompt (auto = automatically)ttl – validity period of the stored location in dayspageNum – number of the page of the visit on which the prompt will be displayedminAccuracy – maximum allowed inaccuracy in meters
Possible location statuses
The geolocation plugin distinguishes between the following statuses, which can be further processed:
unknown-location – The user has neither allowed nor denied the location. The prompt is displayed.
inaccurate-location – The device returned an inaccurate location (e.g., desktop without GPS). The location is not considered valid.
device-unavailable – The device does not have access to location data or geolocation is unavailable.
located – The user has provided their actual location with the required accuracy.