Highlighted

Can you map a data source to a content modification extension?

I'd like to replace a link on the page with a dynamic link which pulls through the product's brand as a 3 letter acronym, so that I can then create specific html files with that brands size guide.. ie replace: Size guide with Size guide where SPY = the acronym for the Spyder brand. I have put the value "product_brand" into the data layer of the page which is working correctly, I just don't know how to pull it into the content modification extension. Any help on this would be gratefully received!
4 REPLIES 4
Highlighted

Can you map a data source to a content modification extension?

Employee Emeritus
Hi Hazel, The Content Modification extension can only be used to write HTML. It won't process JavaScript which means the data source isn't accessible. However, what you're trying to do can be done via a JavaScript Code extension, though. If you feel comfortable doing that we can point you in the right direction, if not, you may want to contact your Account Manager so we can write it for you.
Highlighted

Can you map a data source to a content modification extension?

Employee Emeritus
Hi Hazel; Adding to Son's response, here is a code snippet in the Javascript Code Extension that should do the trick , I tested this out in my sandbox, and it seems to work. In the extension, if you add the following code snippet, and as long your website is running Jquery, this should do what you need it to do. I took your requirements literally, so that all you are doing is replacing the anchor tag's href attribute with the replacement href, and that is what this code will do for you. The code to put into the extension is below. {code:javascript} var product_udo=utag.data["product_brand"]; var replace_href="/pws/client/sizeguides/"+product_udo+".html"; jQuery("#productSizeGuide").attr("href",replace_href); {code} Hope this helps guide you in the right direction.
Highlighted

Can you map a data source to a content modification extension?

Employee Emeritus
As a small caveat, if you use this and need it to be conditional (i.e. only running on certain pages/scenarios), you'd also hap to wrap it in a conditional statement.
Highlighted

Can you map a data source to a content modification extension?

Thank you so much both for your help and advice - this will help me get much further forward!