Skip to content

Commit 2655bab

Browse files
author
Moris Kramer
committed
added documentation
1 parent 8e11c17 commit 2655bab

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed

README.md

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Contentsquare TAG SDK
2+
3+
This NPM package offers developers a standardized way of loading Tracking TAG in a non-blocking way from remote
4+
servers. Based on the [Contentsquare SDK](https://docs.contentsquare.com/uxa-en/).
5+
6+
Contentsquare is an analytics platform that helps businesses understand and optimize user experiences on their websites and mobile apps. It provides actionable insights through heatmaps, session recordings, and behavioral analytics, allowing businesses to identify areas for improvement and enhance overall website performance. With its user-friendly interface and powerful data visualization, Contentsquare enables data-driven decision-making to boost conversions and enhance customer engagement.
7+
8+
9+
## Installation
10+
11+
Install the package using NPM:
12+
13+
```console
14+
npm install --save @contentsquare/tag-sdk
15+
```
16+
17+
18+
19+
-------------
20+
21+
## How to Use Contentsquare Tag
22+
23+
24+
### Prerequisites
25+
26+
Before using the Contentsquare tag, make sure you have the following:
27+
28+
- **Contentsquare Account**: Sign up for a Contentsquare account on official website (https://www.contentsquare.com/) and obtain your client ID.
29+
30+
31+
### Steps to Use Contentsquare Tag
32+
33+
Follow the steps below to use the Contentsquare tag on your website:
34+
35+
1. **Include the Contentsquare Script**: In your website's Javascript/Typescript, add the Contentsquare script using the provided client ID. Replace `YOUR_CLIENT_ID` with your actual Contentsquare client ID.
36+
37+
Call the `injectContentsquareScript` function with the necessary options to append the Contentsquare script to the document.head.
38+
39+
```javascript
40+
// Replace 'YOUR_CLIENT_ID' with your actual Contentsquare client ID
41+
injectContentsquareScript({
42+
clientId: 'YOUR_CLIENT_ID',
43+
async: true, // Optional: Set to false to wait for script execution until after document parsing.
44+
defer: false, // Optional: Set to true to defer script execution after document parsing.
45+
integrity: 'YOUR_SCRIPT_INTEGRITY_HASH', // Optional: Provide the integrity hash for script security (if required).
46+
});
47+
```
48+
49+
The function will append the Contentsquare script to the document.head, and it will be fetched and executed accordingly based on the provided options.
50+
51+
52+
2. **Trigger Page View Tracking**: Once the Contentsquare script is included on your website, it automatically tracks page views by default. No additional code is required to track basic page views. // TODO: is it still true for SPA??
53+
54+
3. **Track Custom Events**: Use the Contentsquare JavaScript API to track custom events on your website. For example, you can track clicks, form submissions, video interactions, and other user interactions. Refer to the Contentsquare documentation for details on how to use API.
55+
56+
57+
```html
58+
<!-- Example: Tracking a click event -->
59+
<script>
60+
window._uxa = window._uxa || [];
61+
window._uxa.push(['trackEvent', 'CLICK_EVENT_NAME']);
62+
</script>
63+
64+
```
65+
66+
4. **User Identification**: To associate user behavior with specific users, you can set the user ID using the `setUserId` method. This allows you to analyze the behavior of individual users in your analytics.
67+
68+
```html
69+
<!-- Example: Setting the user ID -->
70+
<script>
71+
window._uxa = window._uxa || [];
72+
window._uxa.push(['setUserId', 'USER_ID']);
73+
</script>
74+
```
75+
76+
5. **View Analytics Reports**: After implementing the Contentsquare tag on your website, you can log in to your Contentsquare account and access detailed analytics reports, including heatmaps, session replays, conversion funnels, and more.
77+
78+
## Additional Configuration (Optional)
79+
80+
The Contentsquare tag provides additional configuration options to customize your analytics tracking. Refer to the [Contentsquare documentation](https://docs.contentsquare.com/uxa-en/) for more information on configuring advanced settings, enabling specific modules, and handling specific use cases.
81+
82+
---
83+
84+
85+
## API Reference
86+
87+
### `injectContentsquareScript(scriptOptions)`
88+
89+
Injects the Contentsquare script into the document.head.
90+
91+
- `scriptOptions`: Options for injecting the script.
92+
- `clientId` (string) - **(Required)** The client ID provided by Contentsquare in the form of 'a6f73d509'.
93+
- `defer` (boolean) - (Optional) Indicates if the script is fetched in parallel and evaluated after the document is parsed. Defaults to `false`.
94+
- `async` (boolean) - (Optional) Indicates if the script is fetched in parallel and evaluated as soon as possible. Defaults to `true`.
95+
- `integrity` (string) - (Optional) The integrity hash (SRI) of the Contentsquare script. Must be generated by Contentsquare.
96+
97+
**Returns**: The script element representing the Contentsquare script that was appended to `document.head`. Can be used for further manipulation or tracking loading state.
98+
99+
## Restrictions
100+
* This bootstrap mode will only be available for the modern “Contentsquare Deployment” mode (no support for Clicktale or any other legacy modes).
101+
* Some functions within the package will include inline descriptions/types for ease of use, but not all functionality is covered. Please refer to the official [Contentsquare documentation](https://docs.contentsquare.com/uxa-en/) for more information on the available functions and their usage.
102+
103+
## License
104+
105+
This utility is open-source and distributed under the Copyrighted License. Please don't modify or redistribute the code without explicit permission from Contentsquare.
106+
107+
---
108+

0 commit comments

Comments
 (0)