I am creating a AB Test with VWO. For this test I want to take the name out of the url and insert it in a link element. What I have works functionally, but an error appears in the console. I don't understand why and how I can solve it.
vwo_$(document).ready(function() {
vwo_$('BODY > SCRIPT:first-child + HEADER + MAIN > DIV#content:first-child > SECTION:first-child > DIV:first-child > DIV:first-child > DIV:first-child + DIV > ASIDE:first-child > DIV:first-child + DIV + A').replaceWith("<a id=\"ABtestelement\" href=\"/anastia/blog\">Homepage blog ↑</a>");
var XXXXXURL = window.location.href;
var XXXXXURLsplit = XXXXXURL.toString().split("/");
// Returns full URL
document.getElementById("ABtestelement").text = 'Meer blogposts van '+ XXXXXURLsplit[3] +' ↑';
});
The error it gives:
Uncaught TypeError: XXXXXURL.split is not a function
Updated the code: I first add the ID to the element, I know it is not the correct way to to it, but the other function to target it did not work.
I found the problem and you were all right! Apparently, I also added half the code to the global Javascript of all variations causing the error. Thanks for your help.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.