Rich-text Reply

How can I add a link through the editor and append it with the query string of the incoming url?

arose2001 02-11-15

How can I add a link through the editor and append it with the query string of the incoming url?

Hello,

 

I appreciate any help in advance! 

 

Basically, I want to add a link to one of the variations.  All incoming traffic to the site has query parameters like this "?source=google".  Is there any way I can pull the incoming query string and append it to my test link so we dont lose tracking when someone clicks on it?

 

Thanks!

Brian_Abad 02-12-15
 

Re: How can I add a link through the editor and append it with the query string of the incoming url?

Thanks for the question!

 

If you are familiar with jQuery selectors, we can target the anchor tag that you are looking to edit and append the query parameters present on the page to the link. Here's the code that accomplishes that:

 

//grab the current link of the anchor tag and set it to a variable
var newLink = $('SELECTOR_OF_ANCHOR_TAG').attr('href');

//set the link for the anchor tag to include any query parameters present on the page
$('SELECTOR_OF_ANCHOR_TAG').attr('href', newLink + window.location.search);

 

This will be inserted at the bottom of the < edit code > box of the variation created. 

 

Please let me know if you have any questions regarding this! It's a bit more technical but should accomplish what you're looking to do.

 

 

Thanks!

---
Brian Abad
Manager, Technical Support
Customer Success
Optimizely