Expand my Community achievements bar.

How To Trigger an A/B Test in Adobe Target with a User Clicking an On-Page Element

Avatar

Level 1

Hello Everyone,

 

I'm new to using Adobe Target and wondering if there is a way to trigger the activation of an A/B test only after a user on the site has clicked on an on-page element. The element in question is a main menu dropdown, and clicking the element reveals the dropdown menu below. The A/B test makes changes to the content of the dropdown, so we don't want the data collected from that test to include anybody who has not yet clicked on the menu (and would not yet have seen the content the test changes).

 

I have seen a couple solutions to similar questions:

- creating a URL parameter that the second A/B test could watch for likely won't work in this case if it means the whole page has to reload, this would mean the user could never successfully see the dropdown if the page reloads every time they try to access it

 

- I found a solution [1] involving creating a custom mbox, offer, and audience - but it is not clear to me how this would be implemented in Adobe Target or even what an mbox or offer are. If this is a workable solution can somebody explain in more detail so I can implement it?

 

How can an A/B test be triggered programmatically after a user has clicked on an on-page element on the site? Thanks!

Note 1: https://experienceleaguecommunities.adobe.com/t5/adobe-target-discussions/is-there-a-way-to-add-cond...

1 Reply

Avatar

Community Advisor

Hello @innovati,

you can write an activity that executes the following code accordingly when you click on the element. So e.g. wait via JavaScript until the element exists and then put a click event on it. 

 

 

adobe.target.getOffer({
    "mbox": "customMbox123",
    "success": function (offer) {
        adobe.target.applyOffer({
            "mbox": "customMbox123",
            "offer": offer
        });
    },
    "error": function (status, error) {
        console.log('Error', status, error);
    }
});

In the actual Activity corresponding to the mbox customMbox123 e.g. execute code.

 

Hope this helps you.

 

Best regards