ietf-tools / www

A customized CMS for the IETF website
BSD 3-Clause "New" or "Revised" License
25 stars 44 forks source link

feat: A/B testing using wagtail-ab-testing #369

Open mgax opened 9 months ago

mgax commented 9 months ago

Fixes https://github.com/ietf-tools/wagtail_website/issues/173 by implementing wagtail-ab-testing. Adds the ability to track four types of goals:

For the Submit donation form goal type, for tracking to work, a line of code needs to be added in the page editor, to the Raw html block which contains the donation form: wagtailAbTesting.triggerEvent("submit-donation-form"). It should be added at the end of the onApprove callback.

diff --git a/raw.html b/raw.html
index e26e6d2..38c2bce 100644
--- a/raw.html
+++ b/raw.html
@@ -362,6 +362,7 @@ function loadAndRender(transactionType) {
               // alert('Transaction completed by ' + details.payer.name.given_name);
               // alert('Order ID ' + details.id);
               thankYou(details);
+              wagtailAbTesting.triggerEvent("submit-donation-form");
             });
           },
           onError: (err) => {

Additionally, to show the right page version to visitors (control or variant), a Cloudflare worker needs to be set up.

mgax commented 9 months ago

@ghwood wagtail-ab-testing can track two flavours of goal:

  1. User lands on a page and optionally performs a specific action (e.g. click on an outbound link, or make a donation).
  2. User performs an action on any page.

In this PR I've implemented all goals as type "1", i.e. when you set up an experiment, you always need to select a target page. Would it make sense to have some of the goal types be independent of the page? I'm thinking perhaps of the donation goal.

Please note that a goal type can only be page-specific or page-agnostic; if you'd like to have both, then we'd implement it as two different goal types.

mgax commented 7 months ago

Hi @ghwood, @kesara, just wanted to check in to see if I can help unblock this PR?

kesara commented 7 months ago

@mgax, Thanks. I'm just waiting until we get the current infrastructure move complete.