Skip to main content
All CollectionsSilktide AnalyticsAnalytics API
How to record an event from a server
How to record an event from a server
Jessica Chambers avatar
Written by Jessica Chambers
Updated over a week ago

You can record Silktide Analytics events from your backend server, for example if you wish to record downloads provided by a web server.

Unlike recording JavaScript events, this requires slightly more work to set up.

Identifying your API details

First you need to identify your Endpoint URL and Property key.

Endpoint URL

To find your Endpoint URL, open a webpage that uses your Silktide Analytics, then open the dev console in your browser. For example if you're using Chrome, select:

  1. View

  2. Developer

  3. Developer Tools

  4. Console

In the console, enter:

window.stConfig.endpointUrl

Your browser will respond with the URL of the endpoint, for example https://a.eu.silktide.com/v1/events. You should make a note of this.

If your browser instead returns an error, this page is not using the Silktide Analytics script.

Property key

Next, you will need to find your Property Key.

In the console, enter:

window.stConfig.propertyKey

The key returned is your Property Key, a 32-character string of numbers and letters. Keep a record of this, you’ll need it for the next step.

Making an API call

You should make an HTTP POST request to the Endpoint URL you identified above, passing the Property Key in the request.

Your request must have a Content-Type of application/json.

Example request format:

{
"propertyKey":"8bce2be8c07a84a70e7104634b42878b",
"url":"https://silktide.com/",
"ip":"84.14.132.114",
"viewWidth":979,
"userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36",
"events":[
{
"event":"download",
"url":"https://example.com/downloaded-file.pdf"
}
]
}
  • propertyKey, the Property Key, as identified above

  • url, the full URL of the current page. Note that if the URL does not belong to the specified Property, the event will be discarded.

  • ip, the IP address of the visitor making the request. This is required to create a unique temporary identifier for the visitor. The IP address is never stored, will be anonymized, and only a non-reversible, short-term hash is retained by Silktide. If the IP address is blocked, for example because it comes from a known bot, the event will be discarded.

  • viewWidth, the visitor's browser window view width.

  • userAgent, the User Agent of the visitor making the request. This is used to identify the approximate browser and OS of the visitor, as well as to contribute towards their unique temporary identifier. The User Agent itself is never recorded.

  • events, a list of Events and their properties. Each event must have an event property containing the name of the event, other properties depend on the event type being recorded.

Did this answer your question?