How to amend one data source on the order confirmation page to create a new data source

hazel_whicher
Not applicable
hazel_whicher
Hi there, We have a data source called "customer_email". If the customer logs in whilst going through the checkout process, on the order confirmation page, customer_email = customer@email.com However, if the customer goes through the guest checkout process, customer_email = customer@email.com_SPQWsa1l23szA_20140220140552 I have placed an order and used the chrome dev tools console to write the following string: utag_data.customer_email.slice(0, utag_data.customer_email.indexOf("_SPQ")); This strips off everything after _SPQ leaving me with a cleaned customer email address. However, I can't now get it to work in tealium. I have create a 'set data values' extension to set a new data source 'customer_email_clean' to JS Code "jQuery('utag_data.customer_email.slice(0, utag_data.customer_email.indexOf("_SPQ")')" With a condition that customer_email is populated and the extension scoped to all tags. However, I've published and tested and can't see the data source customer_email_clean appearing in utag_data. I have a feeling that I've referenced "utag_data.customer_email" incorrectly - that I perhaps shouldn't mention the utag_data in this extension? Any assistance would be gratefully received! Many thanks, Hazel
6 REPLIES 6

How to amend one data source on the order confirmation page to create a new data source

jared_hislop
Employee Emeritus
jared_hislop
Hey Hazel, Try this in the Set Data Values Extension: b.customer_email.slice(0, utag_data.customer_email.indexOf("_SPQ")) Leave the Type set to JS Code. You can use utag_data in the extensions as well, but typically we recommend using the "b" object when referencing variables in extensions.

How to amend one data source on the order confirmation page to create a new data source

nicholas_earl
Not applicable
nicholas_earl
Hi Hazel, Instead of "utag_data.customer_email", have you tried "b.customer_email"? I typically find that I only need to prefix with "utag_data." if I'm using the "javascript code" extension and it's scoped to pre-loader. Most of the time it seems you need to use "b." -Nick

How to amend one data source on the order confirmation page to create a new data source

hazel_whicher
Not applicable
hazel_whicher
Hi Jared and Nick - thanks for the speedy replies! I changed it to this: jQuery('b.customer_email.slice(0, b.customer_email.indexOf("_SPQ")') and republished, but to no avail - I can't see the new data source customer_email_clean in utag_data in the console. (I'd made sure that the utag.js had updated before I placed the order)

How to amend one data source on the order confirmation page to create a new data source

son_hoang
Employee Emeritus
son_hoang
Hey Hazel, if you still haven't been able to make this work, please contact your account manager so we can take a closer look.

How to amend one data source on the order confirmation page to create a new data source

hazel_whicher
Not applicable
hazel_whicher
No problem. Thanks.
Highlighted

How to amend one data source on the order confirmation page to create a new data source

andrew_rose
Not applicable
andrew_rose
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.