Integrations
Integrating JavaScript SDK with Nextjs App
Follow the steps below to integrate Castled JS SDK with your Nextjs app.
Install the SDK
To install the SDK via npm, run the following command:
Integration with the project
-
Create the following file in the
pages
directory within your projectuseCastledAnalytics.tsAPP-ID
is a unique id associated with your Castled workspace. It can be found in the Castled dashboard at Settings > Api Keys.SERVER-URL
is the cluster url where the events are initially send to.https://api.castled.io
is the default value of this url.
-
Sample code snippet below shows how you would use the
useCastledAnalytics
method created in previous step for tracking user events. -
Once you integrate the SDK and add the code snippets to enable tracking, you will be able to verify the tracking api calls in your browser by inspecting network calls. For e.g. following image shows an instance of
identify
call.