- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
10-12-2016 04:09 AM - edited 10-12-2016 07:48 AM
I've answered my own question, but thought I'd share for anyone else:
My initial question
I want to set shipping cost into event7 as a currency metric either in the format:
s.events = "purchase,event7=5.00";
or in s.products
e.g.
s.products=";prod1;1;10.00,;prod2;2;12.00,;shipping;;;event7=5.00";
but am struggling to achieve this using eCommerce extension.
It either ends up appending to every product like this :
s.products=";prod1;1;10.00;event7=5.00,;prod2;2;12.00;event7=5.00,;shipping;;;event7=5.00";
(which inflates the shipping cost recorded)
or it just sets event7 as a single success event like this:
s.events = "purchase,event7";
(which doesn't record a cost value)
I've tried using JS extensions to overwrite s.products, s.events, utag_data.shipping_cost or _cship but to no avail.
Any ideas? Do I have to use do_Plugins to achieve this?
My solution
Yep. I had to use s_doPlugins in a custom Javascript extension.
Just had this code in there:
s.usePlugins = true;
function s_doPlugins(s) {
if(s.events.indexOf("purchase")>-1){
s.events+=",event7="+utag_data.shipping_cost;
}
s.plugins = ""
}
s.doPlugins = s_doPlugins;
And set the scope to Pre-Loader and SiteCatalyst and ran it after the eCommerce extension.
10-12-2016 09:55 AM
Great solution @aliskink. Thank you for sharing!
12-02-2016 06:49 AM
Hi @aliskink,
Just so you know in the Adobe Analytics tag there is a function available to you.
u.addEvent(eventName <(string|array) of events>, data);
This will append this event, along with anyothers that the tag has generated to the s.events
string.
Hope this helps.
Adrian
12-02-2016 06:52 AM
Copyright All Rights Reserved © 2008-2023