Hi Hazel,
This code should not be wrapped in jQuery, but instead should simply be an "if" statement like this:
if (b.customer_email.indexOf("_SPQ") > -1){
b.customer_email = b.customer_email.slice(0, utag_data.customer_email.indexOf("_SPQ"));
}
This will only make changes to the b.customer_email if the _SPQ exists, otherwise it will be left in it's original format.
If you want to create a new variable, let's say, called new_customer_email, then you would simply add an else statement, like this:
if (b.customer_email.indexOf("_SPQ") > -1){
b.new_customer_email = b.customer_email.slice(0, utag_data.customer_email.indexOf("_SPQ"));
}else{
b.new_customer_email = b.customer_email
}
Hope this helps.
... View more