@survicate/survicate-web-package 25.1.0-npm → 25.1.3-npm
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -29
- package/package.json +1 -1
- package/survicate_widget.js +1 -1
package/README.md
CHANGED
|
@@ -1,47 +1,71 @@
|
|
|
1
1
|
# Survicate Web Package
|
|
2
|
-
This package allows you to run a web survey directly in your code.
|
|
3
|
-
It's built on top of [Preact](https://github.com/preactjs/preact) using [Typescript](https://github.com/Microsoft/TypeScript) and [CSS Modules](https://github.com/css-modules/css-modules).
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
`npm install @survicate/survicate-web-package --save`
|
|
3
|
+
This package enables you to integrate Survicate surveys into your web application. Built with [Preact](https://github.com/preactjs/preact), [TypeScript](https://github.com/Microsoft/TypeScript), and [CSS Modules](https://github.com/css-modules/css-modules).
|
|
7
4
|
|
|
5
|
+
## Installation
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
Find your workspace key in the [Survicate Panel](https://panel.survicate.com/o/0/w/0/settings/access-keys).
|
|
7
|
+
Install the package using NPM:
|
|
11
8
|
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const key = "..." // Your key from the panel
|
|
16
|
-
Survicate.init({workspaceKey: key});
|
|
9
|
+
```bash
|
|
10
|
+
npm install @survicate/survicate-web-package --save
|
|
17
11
|
```
|
|
18
12
|
|
|
19
|
-
##
|
|
13
|
+
## Initialization
|
|
20
14
|
|
|
21
|
-
To
|
|
15
|
+
To initialize Survicate, you'll need your workspace key, which can be found in the [Survicate Panel](https://panel.survicate.com/o/0/w/0/settings/access-keys).
|
|
22
16
|
|
|
23
17
|
```javascript
|
|
24
|
-
import Survicate from '@survicate/survicate-web-package/survicate_widget'
|
|
25
|
-
|
|
26
|
-
// Initialize survicate:
|
|
27
|
-
const key = "..." // Your key from the panel
|
|
28
|
-
Survicate.init({workspaceKey: key});
|
|
18
|
+
import Survicate from '@survicate/survicate-web-package/survicate_widget';
|
|
29
19
|
|
|
30
|
-
//
|
|
31
|
-
|
|
20
|
+
// Replace with your actual workspace key
|
|
21
|
+
const workspaceKey = 'Your workspace key';
|
|
32
22
|
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
Survicate.init({ workspaceKey });
|
|
24
|
+
```
|
|
35
25
|
|
|
36
|
-
|
|
37
|
-
Survicate.addEventListener(ApiEvent.questionAnswered , () => console.log('question answered'));
|
|
26
|
+
## Usage Examples
|
|
38
27
|
|
|
39
|
-
|
|
40
|
-
Survicate.removeEventListener(ApiEvent.questionAnswered);
|
|
28
|
+
Here are some common methods you can utilize:
|
|
41
29
|
|
|
30
|
+
```javascript
|
|
31
|
+
import Survicate from '@survicate/survicate-web-package/survicate_widget';
|
|
32
|
+
|
|
33
|
+
// Initialize Survicate and provide user attributes
|
|
34
|
+
const config = {
|
|
35
|
+
workspaceKey: 'Your workspace key',
|
|
36
|
+
traits: {
|
|
37
|
+
'user_id': 'Your user ID here',
|
|
38
|
+
'company_name': 'Value here',
|
|
39
|
+
'subscription_status': 'Value here',
|
|
40
|
+
'signed_up': 'Value here'
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
Survicate.init(config);
|
|
45
|
+
|
|
46
|
+
// Force display a specific survey
|
|
47
|
+
Survicate.showSurvey('survey id', { forceDisplay: true });
|
|
48
|
+
|
|
49
|
+
// Set visitor attributes and retarget afterwards
|
|
50
|
+
Survicate.setVisitorTraits({
|
|
51
|
+
email: 'john_doe@example.com',
|
|
52
|
+
first_name: 'John',
|
|
53
|
+
last_name: 'Doe',
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
Survicate.retarget();
|
|
57
|
+
|
|
58
|
+
// Add an event listener for when a question is answered
|
|
59
|
+
Survicate.addEventListener(Survicate.ApiEvent.questionAnswered, (surveyId, surveyName) => {
|
|
60
|
+
console.log(`A question was answered - survey: ${surveyName} ${surveyId}`);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// Remove the event listener
|
|
64
|
+
Survicate.removeEventListener(Survicate.ApiEvent.questionAnswered);
|
|
42
65
|
```
|
|
43
|
-
*Please refer to the [documentation](https://developers.survicate.com/javascript/methods/) for the rest of the methods.*
|
|
44
66
|
|
|
45
|
-
|
|
67
|
+
For a list of available methods and their detailed usage, please refer to the [Survicate JavaScript API Documentation](https://developers.survicate.com/javascript/methods/).
|
|
68
|
+
|
|
69
|
+
## Changelog
|
|
46
70
|
|
|
47
|
-
|
|
71
|
+
Stay updated with the latest changes and improvements by reviewing the [Survicate JavaScript SDK Changelog](https://developers.survicate.com/javascript/js-sdk-changelog/).
|
package/package.json
CHANGED