POST
/site-views/Create page visit
You can create a page visit occurrence associated with a specific user.
| Attributes | Type | Required | Description |
|---|---|---|---|
| client_user | string | yes | A unique identifier (12 random characters) for the user which is given by User.com automatically. |
| page_domain | string(URL) | yes | A URL of a website. |
| page_path | string | yes | A path (exact location of a page) visited by a user. |
| timestamp | string | yes | A unix format timestamp of a user visit. |
Request
- CURL
- JavaScript
- PHP
- Python
curl -X POST -H "Authorization: Token <your_64_char_api_key>"
-H "Accept: */*; version=2" -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/"
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("accept", "*/*; version=2");
xhr.setRequestHeader("content-type", "application/json");
xhr.send(data);
<?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(
"Accept: */*; version=2",
"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)
Response
{
"id": 54,
"client_user": "Ypp9DQiEZIPl",
"created_at": "2019-10-07T11:39:25.385368Z",
"domain": "http://mysite.com",
"path": "/my-path"
}