diff --git a/content/collections/web_experiment/en/actions.md b/content/collections/web_experiment/en/actions.md index 22610d797..84b54d828 100644 --- a/content/collections/web_experiment/en/actions.md +++ b/content/collections/web_experiment/en/actions.md @@ -1,7 +1,66 @@ --- id: 3ef0ccc6-5e0f-435b-9184-edb809f19210 blueprint: web_experiment -title: Actions +title: Web Experiment Actions updated_by: 0c3a318b-936a-4cbd-8fdf-771a90c297f0 updated_at: 1728666798 --- + +Actions define how variants modify your site. They relate to variants rather than a specific page, and apply to all pages that you target in your experiment. + +Experiment applies variant actions during evaluation. This happens on the initial page load and any time state pushes to or pops from the session history. History state changes also cause the SDK to revert all applied element change and custom code actions before reevaluating and reapplying actions with the update page in mind. + +## Element changes + +Element changes modify existing elements on your site. Web experiment applies these changes by editing the inner text of an element or appending style to the element based on the change you make in the visual editor. + +The visual editor supports the following element changes: + +- Display: Show or remove the element from the DOM. +- Visibility: Show or hide the element. +- Text: Update an element's inner text, color, and size. +- Background: Update a background image or color. + +## URL redirect + +URL redirects load a new URL when a targeted user lands on a targeted page in your experiment. URL redirects happen on the client, and aren't the same as a server redirect with a `3xx` response. + +URL redirects retain any query parameters on the original page URL. For example, you create a variant to redirect users from `https://example.com` to `https://example.com/get-started`. If a user clicks a link `https://example.com?utm_source=facebook`, Web experiment redirects that user to `https://example.com/get-started?utm_source=facebook`. + +## Custom code + +Web experiment applies custom code actions as an optional part of the element changes action. With the custom code action, write custom JavaScript, CSS, and HTML for your site to add elements or customize your site in was the visual editor doesn't support. + +Web experiment applies custom code to your site in the following order: + +1. Adds **CSS** in a `