Rich-text Reply

Testing renaming strings

jchausse 06-12-15

Testing renaming strings

When defining a test, is there a way to seek out elements by their contents and rename them? 


What I'm trying to do is test out of the effectiveness of renaming a document. I'd like to change a specific document's name whenever it appears in a search result page. Of course, I have no idea where it would be on the search page. I'd like to find the title, rename it, and count how many clicks it gets. Any hope of doing something remotely like this? Smiley Happy Thanks!

Level 1

Amanda 06-12-15

Re: Testing renaming strings

How familiar are you with jQuery? This can easily be done with a bit of jquery code that finds and replaces text.


Here's an article that should help walk you through a change like the one you are mentioning:

Here's another article that outlines how to select a headline with certain text:


Here's an example code snippet that finds the H1 on the page and then changes the background color


$( "body" ).find( "h1:contains('Old Title Name')" ).text( "New Title Goes here" );

Would you be willing to share your search result page with us so we can see how the search functions? There's a possibility that you'll need to tweak the code a little to ensure Optimizely dynamically finds the relevant titles (this will be the case if content is created after the initial page load (ie search filters or refine searches that do not use a full page refresh). 


Looking forward to hearing back from you. 



jchausse 06-15-15

Re: Testing renaming strings

Hi Amanda,


That sounds like a great starting point! I've used jQuery a bit, but I'm a little rusty. I think I can work with what you gave me, though! 


Here's a sample search page:


My next question would be how to target the changed links as goals....


Thanks so much for your help!



Level 1
Amanda 06-15-15

Re: Testing renaming strings

@jchausse - thanks for sending along the URL. It actually looks like there is a new page load every time you add a new filter or search for a new term. So, you can just use a regular click goal within Optimizely and just customize the selector. 


In the advanced section of the click goal set-up, you'll be able to enter your own selector or multiple selectors. You can either use a unique ID if the article you are referencing has a unique one, or you can write your own selector that looks for specific title text, or you can use a selector that looks for a specific link. 


I hope this makes sense. Let me know if you need furture clarification.