We offer an easy way to integrate sitesights.io tracking to your node.js backend. Currently we only support ES Modules import.
You can easily install it to any of your projects with npm.
It is best practice to keep one instance per Website API Key for the entirety of your programs lifespan. The following shows how you can import it and initialize with a API Key:
import { SiteSights } from "sitesights-tracking-library-nodejs"
const tracking = new SiteSights.Tracking({
"apiKey": "[API_KEY]"
});
This shows you an example of a page view call:
let resPageView = await tracking.pageView({
"Metrics": {
"Browser": {
"IP": "91.48.119.123",
"UserAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0"
},
"Identify": {
"ClientId": null
},
"Language": {
"Code": "en"
},
"Location": {
"CountryCode": "AF",
"ContinentCode": "AF",
"City": "test",
"Region": null,
"RegionCode": null,
"PostalCode": "33100",
"Timezone": null
},
"Page": {
"Absolute": "https://app.sitesights.io/analytics"
},
"Referrer": {
"Absolute": null
},
"Screen": {
"Width": 200,
"Height": 200
}
}
});
console.log(resPageView);
This shows you an example of an event call:
let resEvent = await tracking.event({
"Name": "test-event",
"Parameters": [
{
"Name": "param1",
"Value": "value2"
},
{
"Name": "param2",
"Value": "value3"
}
],
"Metrics": {
"Browser": {
"IP": "91.48.119.123",
"UserAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0"
},
"Identify": {
"ClientId": null
},
"Language": {
"Code": "en"
},
"Location": {
"CountryCode": "AF",
"ContinentCode": "AF",
"City": "test",
"Region": null,
"RegionCode": null,
"PostalCode": "33100",
"Timezone": null
},
"Page": {
"Absolute": "https://app.sitesights.io/analytics"
},
"Referrer": {
"Absolute": null
},
"Screen": {
"Width": 200,
"Height": 200
}
}
});
console.log(resEvent);