Sharpay Conversion Events
Conversion events allow webmasters to track the actions of site visitors who follow referral links on social networks shared by Sharpay button users. The conversion event can be, for example, a simple click and visit, a form filling and submission, a purchase action.
Visitor conversion events are very significant to websites, webmasters use them as an indicator to measure their online business growth. The Sharpay button users who shared referral links on their social networks will therefore get additional conversion bonuses (set by webmasters) from their referrals.
All the site visitor actions will be recorded as event data and passed to Sharpay system using JavaScript. Thus, webmasters can track almost any visitor activity. Conversion events only work if visitors have clicked on referral links that shared using our Sharpay buttons.
How to create a conversion event
- Go to the Webmasters section and open the Edit project.
- Open the Events tab and click on the Event settings button.
- To create an event, specify its character code (letters of the Latin alphabet, numbers and dashes are allowed).
- Specify the name of the event that will appear in the reports.
- And the size of the Rate, which will be charged to the user for this event.
- Click the Add Event button and save the changes.
Once the event is created to record visitor actions, it cannot be deleted. You can only deactivate it if you do not need it.
Use of events
When the user performs actions determined by the webmaster, the sharpayAPI.send
JavaScript method is called, to which the code specified during the creation is sent and, if necessary, the callback
function to process the call result.
* To solve possible problems when sending events, we recommend disabling the asynchronous loading of the Sharpay script.
Examples of using
Button press
...
<form action="">
...
<input type="button" onclick="sharpayAPI.send('EVENT-CODE');" value="Create order" />
...
</form>
...
Filling the form
...
<form action="" method="get" onsubmit="sharpayAPI.send('EVENT-CODE');">
...
</form>
...
Following a link
...
<a href="…" onclick="sharpayAPI.send('EVENT-CODE');">…</a>
...
* EVENT-CODE
— Event Code
Confirmation of conversion events
Getting user identity
...
var identity = sharpayAPI.identity();
...
or via callback function
...
<a href="…" onclick="sharpayAPI.send('EVENT-CODE', function(data){ data.identity; });">…</a>
...
Send confirmation request
POST /rest/eventConfirm HTTP/1.1
Host: app.sharpay.io
Accept: application/json
Accept-Charset: utf-8
domain={{domain}}&sid={{sid}}&event={{event}}&identity={{identity}}&hash={{hash}}
curl -H "Accept: application/json"
-d "domain={{domain}}&sid={{sid}}&event={{event}}&identity={{identity}}&hash={{hash}}"
-G https://app.sharpay.io/rest/eventConfirm
<?php
$url = 'https://app.sharpay.io/rest/eventConfirm';
$parameters = [
'domain' => {{domain}},
'sid' => {{sid}},
'event' => {{event}},
'identity' => {{identity}}
];
$parameters['hash'] = md5( implode('', $parameters) );
$headers = [ 'Accepts: application/json' ];
$qs = http_build_query($parameters);
$request = "{$url}?{$qs}";
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $request,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_RETURNTRANSFER => true
));
$response = curl_exec($curl);
print_r(json_decode($response));
curl_close($curl);
?>
from requests import Request, Session, hashlib
from requests.exceptions import ConnectionError, Timeout, TooManyRedirects
import json
url = 'https://app.sharpay.io/rest/eventConfirm'
parameters = {
'domain': {{domain}},
'sid': {{sid}},
'event': {{event}},
'identity': {{identity}},
'hash': hashlib.md5( {{domain}} + {{sid}} + {{event}} + {{identity}} ).hexdigest()
}
headers = {
'Accepts': 'application/json'
}
session = Session()
session.headers.update(headers)
try:
response = session.get(url, params=parameters)
data = json.loads(response.text)
print(data)
except (ConnectionError, Timeout, TooManyRedirects) as e:
print(e)
Parameter | Type | Required? | Description |
---|---|---|---|
domain |
string | required | The site domain name |
sid |
string | required | Site ID in the Sharpay system |
event |
string | required | Event code from events settings in the webmaster section |
identity |
string | required | User identity code |
hash |
string | required | The request hash is the result of the MD5 function from the concatenation of the request values. The order of the values is important (domain, sid, event, identity). |
If successful, you will receive back response:
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
{
"ok": true
}
If any error occurs, you will receive back response:
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
{
"ok": false,
"message": "already confirmed",
"error": 6
}
Sharpay System Limitations
- Conversion events will be accepted by the system only after the end of the minimum visit time, which is indicated in the project settings (Duration of visit).
- Sharpay captures an event from a site visitor no more than once every 5 seconds.
- During one visit of the visitor, the system will record up to 5 conversion events.
- The maximum waiting time for confirmation of an event is 3 days.
- When editing an event, the previously accumulated information does not change.