Create page visit
Create new page visit with HTTP POST request.
POST
/site-views/
Data
Type
Description
client_user (required)
string
Your visitor's key
page_domain (required)
string
Domain on which visitor's presence has been registered
page_path (required)
string
Path on which visitor's presence has been registered.
timestamp
string
Timestamp at which visitor's presence has been registered.
curl -X POST -H "Authorization: Token <your_64_char_api_key>" -H "Content-Type: application/json" -d '{
"client_user": "Ypp9DQiEZIPl",
"page_domain": "http://mysite.com",
"page_path": "/my-path",
"timestamp": "2019-02-18T12:53:17.165251Z"
}' "https://<your_app_subdomain>.user.com/api/public/site-views/"
Response
{
"id": 54,
"client_user": "Ypp9DQiEZIPl",
"created_at": "2019-10-07T11:39:25.385368Z",
"domain": "http://mysite.com",
"path": "/my-path"
}
var settings = {
"async": true,
"crossDomain": true,
"url": "https://<your_app_subdomain>.user.com/api/public/site-views/",
"method": "POST",
"headers": {
"authorization": "Token <your_64_char_api_key>",
"content-type": "application/json"
},
"data": "{
"client_user": "Ypp9DQiEZIPl",
"session_key": null,\n
"referrer_domain": "https://referrer.com",
"referrer_path": "path/",
"page_domain": "http://mysite.com",
"page_path": "/my-path",
"ip_address": "127.0.0.1",
"timestamp": "2019-02-18T12:53:17.165251Z"}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var data = JSON.stringify({
"client_user": "Ypp9DQiEZIPl",
"session_key": null,
"referrer_domain": "https://referrer.com",
"referrer_path": "path/",
"page_domain": "http://mysite.com",
"page_path": "/my-path",
"ip_address": "127.0.0.1",
"timestamp": "2019-02-18T12:53:17.165251Z"
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://<your_app_subdomain>.user.com/api/public/site-views/");
xhr.setRequestHeader("authorization", "Token <your_64_char_api_key>");
xhr.setRequestHeader("content-type", "application/json");
xhr.send(data);
var request = require("request");
var options = { method: 'POST',
url: 'https://<your_app_subdomain>.user.com/api/public/site-views/',
headers: {
'content-type': 'application/json',
authorization: 'Token <your_64_char_api_key>'
},
form: { client_user: 'Ypp9DQiEZIPl',
session_key: null,
referrer_domain: 'https://referrer.com',
referrer_path: 'path/',
page_domain: 'http://mysite.com',
page_path: '/my-path',
ip_address: '127.0.0.1',
timestamp: '2019-02-18T12:53:17.165251Z' },
json: true };
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_PORT => "8000",
CURLOPT_URL => "https://<your_app_subdomain>.user.com/api/public/site-views/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\n \"client_user\": \"Ypp9DQiEZIPl\",\n \"session_key\": null,\n \"referrer_domain\": \"https://referrer.com\",\n \"referrer_path\": \"path/\",\n \"page_domain\": \"http://mysite.com\",\n \"page_path\": \"/my-path\",\n \"ip_address\": \"127.0.0.1\",\n \"timestamp\": \"2019-02-18T12:53:17.165251Z\"\n}",
CURLOPT_HTTPHEADER => array(
"Authorization: Token YxMAaMr0ly4VtE5nvQdzxtALSLnHDWtUuvx4FI54oWnQEgJmJ088kktucqMAmfwD",
"Content-Type: application/json",
"Postman-Token: 4536e8ad-8801-4f25-80bb-aaa1343642ee",
"cache-control: no-cache"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
import requests
url = "https://<your_app_subdomain>.user.com/api/public/site-views/"
payload = "{
"client_user\": \"Ypp9DQiEZIPl\",\n
"session_key\": null,\n
"referrer_domain\": \"https://referrer.com\",\n
"referrer_path\": \"path/\",\n
"page_domain\": \"http://mysite.com\",\n
"page_path\": \"/my-path\",\n
"ip_address\": \"127.0.0.1\",\n
"timestamp\": \"2019-02-18T12:53:17.165251Z\"\n}"
headers = {
'Authorization': "Token YxMAaMr0ly4VtE5nvQdzxtALSLnHDWtUuvx4FI54oWnQEgJmJ088kktucqMAmfwD",
'Content-Type': "application/json",
'cache-control': "no-cache",
'Postman-Token': "c82439d4-21c5-4e5d-9747-fa1a7525667c"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)