From e952370ddc96ed7355a026cfd8f63f0e73d9384b Mon Sep 17 00:00:00 2001 From: Jhonatan Lopes Date: Mon, 19 Feb 2024 14:22:42 -0300 Subject: [PATCH] Custom a/b testing script with nonces --- .../templates/wagtail_ab_testing/script.html | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 network-api/networkapi/templates/wagtail_ab_testing/script.html diff --git a/network-api/networkapi/templates/wagtail_ab_testing/script.html b/network-api/networkapi/templates/wagtail_ab_testing/script.html new file mode 100644 index 00000000000..ba8b7c5357e --- /dev/null +++ b/network-api/networkapi/templates/wagtail_ab_testing/script.html @@ -0,0 +1,53 @@ +{% load static %} + +{% if track %} + {# Is this a Wagtail Page? #} + {% if page %} + {# This value is used to check if a goal has been reached #} + {{ page.id|json_script:"abtesting-page-id" }} + {% endif %} + + {# Is there a test running on the current page? #} + {% if test and version %} + {{ test.id|json_script:"abtesting-test-id" }} + {{ version|json_script:"abtesting-version" }} + {{ test.goal_event|json_script:"abtesting-goal-event" }} + {% if test.goal_page %} + {{ test.goal_page.id|json_script:"abtesting-goal-page-id" }} + {% else %} + {{ None|json_script:"abtesting-goal-page-id" }} + {% endif %} + {% endif %} + + {# URLs #} + {% url 'wagtail_ab_testing:register_participant' as register_participant_url %} + {{ register_participant_url|json_script:"abtesting-register-participant-url" }} + {% url 'wagtail_ab_testing:goal_reached' as goal_reached_url %} + {{ goal_reached_url|json_script:"abtesting-goal-reached-url" }} + + + + +{% endif %} \ No newline at end of file