@dotcms/experiments 0.0.1-alpha

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 ADDED
@@ -0,0 +1,106 @@
1
+ # @dotcms/experiments
2
+
3
+ `@dotcms/experiments` is the official dotCMS JavaScript library that helps add A/B testing to your webapps. It handle user assignments to different variants of a page and tracks their interactions.
4
+
5
+ ## Features
6
+
7
+ - **User Assignment to Experiments**: Automatically assigns users to different experimental variants, ensuring diverse user experiences and reliable test data.
8
+ - **Link Verification for Redirection**: Checks links to ensure users are redirected to their assigned experiment variant, maintaining the integrity of the testing process.
9
+ - **Automatic PageView Event Sending**: Automatically sends PageView events to DotCMS Analytics, enabling real-time tracking of user engagement and experiment effectiveness.
10
+
11
+
12
+
13
+ ## Installation
14
+ You can install the package via npm or Yarn:
15
+
16
+ ```bash
17
+ npm install @dotcms/experiments
18
+ ```
19
+ Or using Yarn:
20
+
21
+ ```bash
22
+ yarn add @dotcms/experiments
23
+ ```
24
+
25
+
26
+ ## Components
27
+
28
+ ### `DotExperimentsProvider`
29
+ This component utilizes React's Context API to provide DotExperiments instances to its descendants, facilitating access to A/B testing features throughout your webapps.
30
+
31
+ #### Props
32
+ - **config**: Configuration object for DotCMS Analytics integration.
33
+ - **apiKey**: Your API key from the DotCMS Analytics app.
34
+ - **server**: The URL of your DotCMS instance.
35
+ - **redirectFn**: The redirect function to use when assigning users to experiment variants.
36
+
37
+ #### Usage
38
+
39
+ ```javascript
40
+ import { DotExperimentsProvider } from "@dotcms/experiments";
41
+ import { useRouter } from 'next/router';
42
+
43
+ const { replace } = useRouter();
44
+
45
+ const experimentConfig = {
46
+ apiKey: 'your-api-key-from-dotcms-analytics-app',
47
+ server: 'https://your-dotcms-instance.com',
48
+ redirectFn: replace // Use replace from useRouter in Next.js
49
+ };
50
+
51
+ return (
52
+ <DotExperimentsProvider config={experimentConfig}>
53
+
54
+ <Header>
55
+ <Navigation />
56
+ </Header>
57
+ <DotcmsLayout />
58
+ <Footer />
59
+
60
+ </DotExperimentsProvider>
61
+ );
62
+ ```
63
+
64
+ ## How A/B Testing Works with @dotcms/experiments
65
+
66
+ The A/B testing process with `@dotcms/experiments` is designed to be straightforward and automatic:
67
+
68
+ 1. **Experiment Assignment**: When a user visits a page that includes an experiment, the library first checks if the user has been assigned to an experiment variant. If not, it queries DotCMS Analytics to determine if there are active experiments and assigns the user to the appropriate variant.
69
+
70
+ 2. **Page Redirection**: If the user's assigned variant differs from the current page, the library automatically redirects the user to the correct variant page. This ensures that the user experiences the variant they have been assigned to.
71
+
72
+ 3. **Tracking Pageviews**: After redirection or upon visiting the page, the library sends a pageview event to DotCMS Analytics. This data is used to determine the effectiveness of each variant, ultimately helping to identify which variant performs better in the A/B test.
73
+
74
+
75
+ ## Learn More About A/B Testing with DotCMS
76
+
77
+ For more detailed information on A/B testing features and capabilities, visit the DotCMS A/B testing and experiments page: [DotCMS A/B Testing Experiments](https://www.dotcms.com/product/ab-testing-experiments).
78
+
79
+
80
+ ## Contributing
81
+
82
+ GitHub pull requests are the preferred method to contribute code to dotCMS. Before any pull requests can be accepted, an automated tool will ask you to agree to the [dotCMS Contributor's Agreement](https://gist.github.com/wezell/85ef45298c48494b90d92755b583acb3).
83
+
84
+ ## Licensing
85
+
86
+ dotCMS comes in multiple editions and as such is dual licensed. The dotCMS Community Edition is licensed under the GPL 3.0 and is freely available for download, customization and deployment for use within organizations of all stripes. dotCMS Enterprise Editions (EE) adds a number of enterprise features and is available via a supported, indemnified commercial license from dotCMS. For the differences between the editions, see [the feature page](http://dotcms.com/cms-platform/features).
87
+
88
+ ## Support
89
+
90
+ If you need help or have any questions, please [open an issue](https://github.com/dotCMS/core/issues/new/choose) in the GitHub repository.
91
+
92
+ ## Documentation
93
+
94
+ Always refer to the official [DotCMS documentation](https://www.dotcms.com/docs/latest/) for comprehensive guides and API references.
95
+
96
+ ## Getting Help
97
+
98
+ | Source | Location |
99
+ | --------------- | ------------------------------------------------------------------- |
100
+ | Installation | [Installation](https://dotcms.com/docs/latest/installation) |
101
+ | Documentation | [Documentation](https://dotcms.com/docs/latest/table-of-contents) |
102
+ | Videos | [Helpful Videos](http://dotcms.com/videos/) |
103
+ | Code Examples | [Codeshare](https://dotcms.com/codeshare/) |
104
+ | Forums/Listserv | [via Google Groups](https://groups.google.com/forum/#!forum/dotCMS) |
105
+ | Twitter | @dotCMS |
106
+ | Main Site | [dotCMS.com](https://dotcms.com/) |
package/index.esm.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./src/index";