Contributing
How to contribute to Woosmap RecommendationContribute to Recommending API Profiles
In order to build profiles and benefit from the recommendation, every implementation must contribute to collecting location data through users’ digital journey. As a reminder, consent must be checked, and obtained if it has not been yet, before contributing to location profiles. Here is the dedicated documentation on this point.
Synchronous and Asynchronous
Like described in the Loading topic, use the corresponding method depending on how
you loaded the recommendation.js
script.
//Synchronous
woosmapRecommendation.sendUserHtml5Position({lat: 43, lng: 3.3});
//Asynchronous
rRequestQueue.push(['sendUserHtml5Position', [{lat: 43, lng: 3.3}]]);
Contributing Use Cases
Send User Searched Position
Below is a sample HTML and Javascript code to allow your visitor to geocode an address. The resulted position will be
pushed to Woosmap Profile using woosmapRecommendation.sendUserSearchedPosition()
<input type="text" name="query" id="queryinput" placeholder="Search an Address">
<input type="submit" id="search-geocoding">
<script>
function geocodeAddress(geocoder) {
var address = document.getElementById('queryinput').value;
geocoder.geocode({'address': address}, function (results, status) {
if (status === google.maps.GeocoderStatus.OK) {
var latitude = results[0].geometry.location.lat();
var longitude = results[0].geometry.location.lng();
//Contribute to Woosmap Profile
woosmapRecommendation.getConsent((consent) => {
if (consent === true) {
woosmapRecommendation.sendUserSearchedPosition({
lat: latitude,
lng: longitude,
successCallback: function () {
// finally, search the assets around your location
searchWoosmapApiAroundLocation(latitude, longitude);
}
});
}
});
} else {
console.log('Geocode was not successful: ' + status);
}
});
}
function init() {
var geocoder = new google.maps.Geocoder();
document.getElementById('search-geocoding').addEventListener('click',
function () {
geocodeAddress(geocoder);
});
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=API_KEY&callback=init">
</script>
Send User Consulted POI
The Recommendation API can improve the user location profile by collecting POIs consulted by a user.
When a user select an item from a stores list (POIs list), call the woosmapRecommendation.sendUserConsultedPOI()
passing the Store Id and location information as parameters.
Check PostPOIPositionOptions reference.
<ul id='stores-list'>
<li data-lat='3.41' data-lng='43.23' data-storeid='1' onclick='favoritedStore(this)'>My Store 1</li>
<li data-lat='2.26' data-lng='42.19' data-storeid='2' onclick='favoritedStore(this)'>My Store 2</li>
</ul>
<script>
function favoritedStore(elem) {
woosmapRecommendation.getConsent((consent) => {
if (consent === true) {
woosmapRecommendation.sendUserConsultedPOI({
lat: elem.getAttribute('data-lat'),
lng: elem.getAttribute('data-lng'),
id: elem.getAttribute('data-storeid'),
successCallback: function () {}
});
}
});
}
</script>
Send User Favorited POI
Instead of posting a consulted POI, you could send a favorited POI by using the woosmapRecommendation.sendUserFavoritedPOI()
. This method takes the same parameters as sendUserConsultedPOI()
.
Send User HTML5 Position
The Geolocation API, natively supported by modern browsers, defines a high-level interface to location information
associated only with the device hosting the implementation, such as latitude and longitude.
Here is a Javascript sample to plug this feature to your website and contribute to Woosmap profiles on success callback
using woosmapRecommendation.sendUserHtml5Position()
.
// Acquire a new position object.
navigator.geolocation.getCurrentPosition(successCallback, errorCallback);
function successCallback(position) {
//Contribute to Woosmap Profile
woosmapRecommendation.sendUserHtml5Position({
lat: position.coords.latitude,
lng: position.coords.longitude,
successCallback: function () {
// finally, search the assets around your location
searchWoosmapApiAroundLocation(latitude, longitude);
}
})
}
function errorCallback(error) {
console.log(error.code)
}
Other Use Cases
You are able to contribute in many other instances like posting the user billing position or a shipping position. Please refer to the API Reference for an exhaustive list of all the ways such contributing could be posted.
Privacy Requirements
Woosmap takes privacy very seriously. In order to be compliant with standard reglementation on data privacy, a website using Woosmap Recommendation must add to its privacy policy the following mention:
- Used cookies: Location cookie
- Description: This cookie is generated by all our websites, mobile websites and mobile applications by a tierce company, Web Geo Services, to collect location data. These data are used by our websites, services or other Web Geo Services’ customers to provide you advanced functionalities such as automatic store or pickup point proximity, with opening schedule.
- Duration: According to the regulation, this cookie has a 13 months life time. Past this time, your consent will be asked again to add a new cookie.
- Processing: Location data are processed by Web Geo Services to develop Geo-location segments and profiles in order to bring you advanced location functionalities on website you browse on.
- Recipient: [Company Name] is the only recipient of those processed data, limited to the data collected from our websites or applications.
- Information: You can access and ask for rectification on data collected by contacting Web Geo Services – Services consommateurs – 19, rue de la République 34000 Montpellier, France or [email protected]
- Opposition: You can, for legitimate motivations, ask to be excluded of the data collection by opting out at this address: https://www.woosmap.com/policies/privacy/