One of the features of the Visual Editor enables you to edit where a link is pointing to.
In short, from URL to another URL.
Generic case
This features is available through the contextual menu when you click on a link element:
Edit -> Edit link
It opens a dedicated modal in which the input is pre-filled with the original URL value of the link:
The value can be an absolute URL (https://www.abtasty.com/contact) or a relative URL (/contact).
You can change the value by typing or copy-pasting another URL and opening it in a new tab or in the same tab.
Once clicked on "Save changes", it will apply the modifications when the AB Tasty tag is executed.
Edge case
In some edge cases (specific single-page-application implementations), the "edit link" feature does not redirect out of the box and you need to add a JavaScript code in the "Add Javascript" feature.
- Click on the variation name to open the variation menu
- Click on "Add JavaScript"
- Paste the following snippet of code:
const link = 'https://www.abtasty.com/'; const selector = '#yourSelector, #anotherSelector'; const openInNewTab = false; const isTargetValid = eventTarget => { const userTargets = [...document.querySelectorAll(selector)]; return userTargets.some(element => { const isTarget = element.isSameNode(eventTarget) || !!eventTarget.closest(selector); return isTarget; }); }; const onClickTarget = (event) => { event.preventDefault(); event.stopPropagation(); if (isTargetValid(event.target)) openInNewTab ? open(link) : location.href = link; }; const listenerParams = ['click', onClickTarget, { capture: true }]; document.addEventListener(...listenerParams);
- Replace "https://www.abtasty.com/" with the link you want to use for redirection.
- Replace "#yourSelector, #anotherSelector" by one of several selectors of the links you want to redirect.
- Click on "Save changes".
Comments
0 comments
Article is closed for comments.