@rebilly/lead-source-tracker 8.20.12 → 8.21.0
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 +21 -19
- package/package.json +26 -26
package/README.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# lead-source-tracker
|
|
2
|
+
|
|
2
3
|
Simple library which is used to collect and store lead source information into a cookie
|
|
3
4
|
|
|
4
5
|
## Contributing
|
|
@@ -18,13 +19,12 @@ Simple library which is used to collect and store lead source information into a
|
|
|
18
19
|
|
|
19
20
|
`import RebillyLeadSource from '@rebilly/lead-source-tracker';`
|
|
20
21
|
|
|
21
|
-
3. Call the `collect` function on each page load to have the tracker collect and save information to the cookie.
|
|
22
|
+
3. Call the `collect` function on each page load to have the tracker collect and save information to the cookie.
|
|
22
23
|
|
|
23
24
|
`RebillyLeadSource.collect(window)`
|
|
24
25
|
|
|
25
26
|
You can provide additional cookie attribues using the second argument:
|
|
26
27
|
|
|
27
|
-
|
|
28
28
|
`RebillyLeadSource.collect(window, { domain: 'rebilly.com', secure: true })`
|
|
29
29
|
|
|
30
30
|
See https://github.com/js-cookie/js-cookie#cookie-attributes for the full list of supported attributes.
|
|
@@ -32,6 +32,7 @@ See https://github.com/js-cookie/js-cookie#cookie-attributes for the full list o
|
|
|
32
32
|
4. Call `collect` again when submitting lead source information to the Rebilly API. The function returns all saved cookie data as an object.
|
|
33
33
|
|
|
34
34
|
Example:
|
|
35
|
+
|
|
35
36
|
```
|
|
36
37
|
const endpoint = 'https://api.rebilly.com/storefront/v1/register';
|
|
37
38
|
|
|
@@ -54,7 +55,7 @@ fetch(endpoint, {
|
|
|
54
55
|
})
|
|
55
56
|
```
|
|
56
57
|
|
|
57
|
-
**Note:** `collect` can only be called from the browser, it will throw an exception if called from a node server.
|
|
58
|
+
**Note:** `collect` can only be called from the browser, it will throw an exception if called from a node server.
|
|
58
59
|
In SSR frameworks like gatsby, this means the function should be called from within an appropriate hook (e.g. `useEffect`).
|
|
59
60
|
|
|
60
61
|
## leadSource data sources
|
|
@@ -75,20 +76,20 @@ Some data is automatically inferred by `RebillyLeadSource` when data collection
|
|
|
75
76
|
|
|
76
77
|
### Query params
|
|
77
78
|
|
|
78
|
-
| key
|
|
79
|
-
|
|
|
80
|
-
| `dnt`
|
|
81
|
-
| `source`
|
|
82
|
-
| `medium`
|
|
83
|
-
| `campaign`
|
|
84
|
-
| `term`
|
|
85
|
-
| `content`
|
|
86
|
-
| `affiliate`
|
|
87
|
-
| `subAffiliate` or `subaffiliate` | `?subAffiliate=example` | Change the leadSource `subAffiliate` field
|
|
88
|
-
| `clickId` or `clickid`
|
|
89
|
-
| `salesAgent` or `salesagent`
|
|
90
|
-
| `path`
|
|
91
|
-
| `referrer`
|
|
79
|
+
| key | example | purpose |
|
|
80
|
+
| -------------------------------- | ----------------------- | -------------------------------------------------------------------------------------------- |
|
|
81
|
+
| `dnt` | `?dnt=true` | Setting `dnt` will cause RebillyLeadSource to stop tracking that user. |
|
|
82
|
+
| `source` | `?source=example` | Change the leadSource `source` field |
|
|
83
|
+
| `medium` | `?medium=example` | Change the leadSource `medium` field |
|
|
84
|
+
| `campaign` | `?campaign=example` | Change the leadSource `campaign` field |
|
|
85
|
+
| `term` | `?term=example` | Change the leadSource `term` field |
|
|
86
|
+
| `content` | `?content=example` | Change the leadSource `content` field |
|
|
87
|
+
| `affiliate` | `?affiliate=example` | Change the leadSource `affiliate` field |
|
|
88
|
+
| `subAffiliate` or `subaffiliate` | `?subAffiliate=example` | Change the leadSource `subAffiliate` field |
|
|
89
|
+
| `clickId` or `clickid` | `?clickId=example` | Change the leadSource `clickId` field |
|
|
90
|
+
| `salesAgent` or `salesagent` | `?salesAgent=example` | Change the leadSource `salesAgent` field |
|
|
91
|
+
| `path` | `?path=example` | Change the leadSource `path` field. This cannot be updated once it is set the first time |
|
|
92
|
+
| `referrer` | `?referrer=example` | Change the leadSource `referrer` field. This cannot be updated once it is set the first time |
|
|
92
93
|
|
|
93
94
|
All leadSource query params will also work if prefixed with `utm_`. e.g. `?utm_campaign=campaign1`
|
|
94
95
|
|
|
@@ -114,7 +115,8 @@ leadSource data can be added to this element using `data-` attributes.
|
|
|
114
115
|
data-sales-agent="..."
|
|
115
116
|
data-click-id="..."
|
|
116
117
|
data-path="..."
|
|
117
|
-
data-referrer="..."
|
|
118
|
+
data-referrer="..."
|
|
119
|
+
/>
|
|
118
120
|
</body>
|
|
119
121
|
```
|
|
120
122
|
|
|
@@ -127,4 +129,4 @@ The following fields will not be updated after the first time they are saved to
|
|
|
127
129
|
|
|
128
130
|
The only exception is if the cookie expires (after 45 days) or is cleared by the user.
|
|
129
131
|
|
|
130
|
-
All other fields will update the saved cookie whenever `collect` is called.
|
|
132
|
+
All other fields will update the saved cookie whenever `collect` is called.
|
package/package.json
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
2
|
+
"name": "@rebilly/lead-source-tracker",
|
|
3
|
+
"version": "8.21.0",
|
|
4
|
+
"description": "Simple library which is used to collect and store lead source information into a cookie",
|
|
5
|
+
"author": "Rebilly",
|
|
6
|
+
"repository": "https://github.com/Rebilly/rebilly",
|
|
7
|
+
"main": "dist/build.js",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"serve": "pnpm build && node ./dev/server.js",
|
|
13
|
+
"build": "vite build"
|
|
14
|
+
},
|
|
15
|
+
"browserslist": [
|
|
16
|
+
"> 1%",
|
|
17
|
+
"last 2 versions"
|
|
18
|
+
],
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@rebilly/eslint-config": "*",
|
|
21
|
+
"express": "^5.1.0",
|
|
22
|
+
"vite": "^5.4.21",
|
|
23
|
+
"vite-plugin-commonjs": "^0.10.4"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"js-cookie": "^3.0.7"
|
|
27
|
+
}
|
|
28
28
|
}
|