How to record an event from a server

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 API endpoint and Property key.

To do this, open a webpage that uses your Silktide Analytics in your browser, open the dev console (in Chrome, View > Developer > Open Developer Tools, and click Console). In the console, enter this JavaScript:

window.stConfig.endpointUrl

Your browser will respond with the URL of the endpoint, e.g. 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).

Then enter:

window.stConfig.propertyKey

Whatever it returned will be your Property Key, a 32-character string of numbers and letters like 8634c07a84acb4e2be870e710b42878b. Keep a record of this, you’ll need it for the next step.

Making an API call

You should make a 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:

{
  "propertyKey": "aj40ish7x",
  "url": "https://silktide.com/",
  "ip": "12.34.56.78",
  "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) ...",
  "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 Analytics. If the IP address is blocked (e.g. it comes from a known bot), the event will be discarded.
  • 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 being recorded. See built-in events.

Need extra help?

Chat with our support team now and we'll be happy to help you with any issues