Send an event
You should now turn your attention to the server. First, check you are now receiving a probe_id
along with any other details you want to send along with the event (email, phone, etc.).
Not receiving the probe_id
field?
- Inspect the HTML of the form, can you see the agent code? If not, check it's deployed properly.
- If you're using our convenience method (option 1) check that the form field has the
data-hp-site-key="<INSERT_SITE_KEY>"
attribute and of course that it's within the<form></form>
tags. - Double check the site key is correct.
- If you have a CSP (Content Security Policy), did you add Hitprobe's domains to it in the previous step?
Now you have the probe_id
, go ahead and send it to the event API along with (optionally) any other details about the visitor you want to include.
- cURL
- Ruby
- Node
- PHP
- Python
- Go
- .NET
- Java
curl 'https://app.hitprobe.com/api/v1/event' \
-H 'Content-Type: application/json' \
--data '{
"email": "[email protected]",
"probe_id": "<INSERT_PROBE_ID>",
"ip": "<INSERT_REMOTE_IP>",
"secret_key": "<INSERT_SECRET_KEY>"
}'
require 'net/http'
require 'json'
uri = URI('https://app.hitprobe.com/api/v1/event')
req = Net::HTTP::Post.new(uri)
req.content_type = 'application/json'
req.body = {
'email' => '[email protected]',
'probe_id' => '<INSERT_PROBE_ID>',
'ip' => '<INSERT_REMOTE_IP>',
'secret_key' => '<INSERT_SECRET_KEY>'
}.to_json
req_options = {
use_ssl: uri.scheme == 'https'
}
res = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
http.request(req)
end
import fetch from 'node-fetch';
fetch('https://app.hitprobe.com/api/v1/event', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
'email': '[email protected]',
'probe_id': '<INSERT_PROBE_ID>',
'ip': '<INSERT_REMOTE_IP>',
'secret_key': '<INSERT_SECRET_KEY>'
})
});
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client();
$response = $client->post('https://app.hitprobe.com/api/v1/event', [
'headers' => [
'Content-Type' => 'application/json'
],
'json' => [
'email' => '[email protected]',
'probe_id' => '<INSERT_PROBE_ID>',
'ip' => '<INSERT_REMOTE_IP>',
'secret_key' => '<INSERT_SECRET_KEY>'
]
]);
import requests
headers = {
'Content-Type': 'application/json',
}
json_data = {
'email': '[email protected]',
'probe_id': '<INSERT_PROBE_ID>',
'ip': '<INSERT_REMOTE_IP>',
'secret_key': '<INSERT_SECRET_KEY>',
}
response = requests.post('https://app.hitprobe.com/api/v1/event', headers=headers, json=json_data)
package main
import (
"fmt"
"io"
"log"
"net/http"
"strings"
)
func main() {
client := &http.Client{}
var data = strings.NewReader(`{
"email": "[email protected]",
"probe_id": "<INSERT_PROBE_ID>",
"ip": "<INSERT_REMOTE_IP>",
"secret_key": "<INSERT_SECRET_KEY>"
}`)
req, err := http.NewRequest("POST", "https://app.hitprobe.com/api/v1/event", data)
if err != nil {
log.Fatal(err)
}
req.Header.Set("Content-Type", "application/json")
resp, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
bodyText, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s\n", bodyText)
}
using System.Net.Http;
using System.Net.Http.Headers;
HttpClient client = new HttpClient();
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "https://app.hitprobe.com/api/v1/event");
request.Content = new StringContent("{ \"email\": \"[email protected]\", \"probe_id\": \"<INSERT_PROBE_ID>\", \"ip\": \"<INSERT_REMOTE_IP>\", \"secret_key\": \"<INSERT_SECRET_KEY>\" }");
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
HttpResponseMessage response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpRequest.BodyPublishers;
import java.net.http.HttpResponse;
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://app.hitprobe.com/api/v1/event"))
.POST(BodyPublishers.ofString("{ \"email\": \"[email protected]\", \"probe_id\": \"<INSERT_PROBE_ID>\", \"ip\": \"<INSERT_REMOTE_IP>\", \"secret_key\": \"<INSERT_SECRET_KEY>\" }"))
.setHeader("Content-Type", "application/json")
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
The payload should be a JSON object containing the probe_id
, the remote IP address (i.e. the user's IP), your secret key, and the details the user provided.
For example:
{
"probe_id": "ctwCYFyAUteNpsBgAw7xYL",
"email": "[email protected]",
"name": "Dan Gerous",
"phone": "(212) 664-7665",
"ip": "204.158.96.40",
"address": {
"address1": "35 Lodgeville Rd",
"address2": "",
"city": "",
"state": "Minnesota",
"country": "US",
"postal_code": ""
},
"secret_key": "3748eaee-7408-4fee-9e42-4d5d94e5f2e9"
}
We'll look at each of the properties in the JSON payload next.
All the fields are optional, but of course for best results you'll want to provide as many data points as possible. If you prefer, you can provide only the probe_id
to get only device info, or just an ip
and email
if you only need to check the IP and email address. It's up to you.
Secret key
You'll find the secret key under the site's settings in the console.
Probe ID
Send the probe_id
generated by the client-side agent. The API will accept empty or malformed IDs at this point but will mark them as invalid in the result.
IP address
The IP address should be the remote server IP address (i.e. the end-user's public IPv4 or IPv6 address). Providing an IP address is helpful as it allows the integrity of the probe data to be checked, and acts as a fallback if the probe is not valid.
See our additional information about capturing IP addresses, as proxies can have an impact on how you collect the IP.
Email and name
Provide the email address and full name of the customer.
Phone
The customer's phone number, in any format.
Hitprobe will try to coerce any phone number string into E.164 (international) format. For locally formatted numbers, it will use the site's country (in site settings) to do this accurately.
Address
Provide an address
object using any or all of the keys in the address property. The input is essentially freeform. Hitprobe will attempt to parse and normalise the address.
More information
Remember, this is a shortened guide to help you get started. You can skip to full details about the API request now if you prefer.