Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...


Code Block
languagejs
themeEclipse
linenumberstrue
const share = function(){
navigator.share({
title: 'mobsted.com',
text: 'Check out mobsted platform',
url: 'https://mobsted.com/?utm_referal_objectid=#Object:objid#',
})
.then(() => console.log('Successful share'))
.catch((error) => console.log('Error sharing', error));
}

if (navigator.share) {
document.getElementById("btnShare").onclick = share
share()
} else {
document.getElementById("btnShare").onclick =
() => alert('Sharing does not work');
} 



NOTE the URL link above (line 5) - needs to lead to the place in your app, where you want to land all the new users. It can be a certain screen in your app, or a Common Access Link from the Security section of the app, or a screen in a landing-page kind of app, so not the same one from where sharing is made. All depends on the task at hand.

An example of such URL could be - https://a15ef654.mobsted.com/pwa/?appid=17

Title and text (lines 3 & 4)  - what the native sharing function of a user's device will show during the process.

...

"?" denotes start of the URM mark

"utm_referal_objectid"  is a name you give this UTM mark, any name here will do, as long as it has no spaces

#Object:objid# is a hashtag to get the right column from Objects. But you can use anything, like a phone number, or email or object's UUID good option - #Object:uuid# (which is better in our opinions, as it is randomthe random hash).



STEP 3 - Recording Referrers into new user's data

...


The general form is #Route:query:custom_name#. In the case on the picture above ↑ we called that custom_name as "utm_referal_objectid", which takes the UTM variable created on Step 2 (JS code line 5).



Alternative Route

You can place sharing function to a custom button, not the element taken from the palette on your left. 


In this case you will need to take care of Errors in JS and change:


Button's JS Action (recommended)Custom JS
if (navigator.share) {
share()
} else {
alert('Sharing not works');
}
if (navigator.share) {
document.getElementById("btnShare").onclick = share
} else {
document.getElementById("btnShare").onclick = () => alert('Sharing does not work');
}


In the Custom JS case, you need to create buttons or link on your own and also you must take into account different naming for each element, so name each sharing Custom JS block's button as "btnShare", "btnShare1", "btnShare2" and so on, other wise only the first script will work. 




Thats all. Ask us anything we missed here.