www icon indicating copy to clipboard operation
www copied to clipboard

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

Open mgax opened this issue 1 year ago • 3 comments

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

  • Visit page: user visits a page of the website (this is the built-in goal of wagtail-ab-testing).
  • Navigate to registration website: user clicks a link whose URL begins with https://www.ietf.org/mailman/listinfo/.
  • Navigate to Mailman website: user clicks a link whose URL begins with https://registration.ietf.org.
  • Submit donation form: user submits the PayPal donation form.

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 avatar Dec 18 '23 14:12 mgax