wagtail-nest / wagtail-ab-testing

A/B testing for Wagtail

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

conversions don't get tracked

mwesterhof opened this issue · comments

After failing to get ab testing working on an existing wagtail project, I tried following the installation steps for a minimal project, with no more luck.

The installation itself works fine, the migrations run without issues and i can successfully create an A/B test. It also seems to correctly track unique visitors for the page under test. However, it seems that successful conversions (page visits of a goal page) are never picked up. I checked the django views where the conversions are supposed to be picked up, but those are never called. My best guess so far is that there's something going wrong in the tracker JS, but i'm at a loss what the issue might be.

I think this might be a bug or slight hitch in documentation on wagtail-ab-testing's side, but i pushed my minimal project setup to a separate repo, in the hopes this will help point to the reason for the issue

Hi @mwesterhof, I appear to be having the same issue as you.

Everything now appears to be working fine using:
wagtail 2.16.2
wagtail_ab_testing 0.7

Apart from the conversions are not logged. Did you have any success in finding a solution for this?

I've also noticed the A/B Testing tab in the edit section of pages appears to be missing. The results can still be found in the Reports section. I just need to work out how to pull it back in as we've modified edit_handlers

Update: I've also tried this with the code from the 3.0 MR as it mentions changes for 2.15 and 2.16. I'm still not seeing conversions being tracked.

Local storage is correctly showing the target page ID, event goal type and the test ID {"82":{"visit-page":[4]}} for abtesting-goals. When the target page ID is visited, the event goal type and the test Id are removed from the array {"82":{}}.

wagtailAbTesting appears to contain all of the relevant information for both the test page and the target page

TEST PAGE

<script>
        window.wagtailAbTesting = {
                        
            pageId: 4618,
           
            testId: 4,
            version: 'control',
            goalEvent: 'visit\u002Dpage',
            goalPageId: 82,
            
            urls: {
                
                registerParticipant: '/abtesting/register\u002Dparticipant/',
                
                goalReached: '/abtesting/goal\u002Dreached/',
            }
        };
    </script>

GOAL PAGE

<script>
        window.wagtailAbTesting = {

            pageId: 82,
            
            urls: {
                
                registerParticipant: '/abtesting/register\u002Dparticipant/',
                
                goalReached: '/abtesting/goal\u002Dreached/',
            }
        };
    </script>

Did a quick look today, problem seems to be indeed in tracker.js.

Here's my fix:

Line 43 (Original):

goals[window.wagtailAbTesting.goalPageId] = goals[window.wagtailAbTesting.goalPageId] || {}

Problem:

Missing closing semicolon (Not sure if this affects anything but I added the closing semicolon just in case.

Changed to:

goals[window.wagtailAbTesting.goalPageId] = goals[window.wagtailAbTesting.goalPageId] || {};

Line 67 (Original):

document.cookie = cookieName + '=' + window.wagtailAbTesting.version + '; expires=' + expires.toUTCString();

Problem:

Path is not set, so by default this will set the current page path as the cookie's path, making it only accessible in the page it is set in

Changed to:

document.cookie = cookieName + '=' + window.wagtailAbTesting.version + '; path=/; expires=' + expires.toUTCString();

Note: I haven't tested this further, so I am not sure if setting the path will cause any problem elsewhere.