Analytics
4.6K members online now
4.6K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

eCommerce tracking - editing added product

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi,

I'm working with a system that automatically adds analytics ecommerce codes for my website - for tracking adding products, impressions etc in various phases of the purchase flow (viewing products, cart, checkout, order approval, etc). for example on checkout:

 

ga('ec:setAction', 'checkout');

ga('ec:addProduct', {'id':'1010974', 'name':'Atopica 10 mg, 15 Capsules ', 'category':'Allergy Medicine', 'brand':'Novartis Animal Health', 'variant':'', 'price':38.8300, 'quantity': 1 });

ga('send', 'event', 'checkout', 'start', 'On Checkout Page');

 

and for impressions:

 

ga('ec:setAction', 'detail');
ga('ec:addImpression', {'id':'1010974', 'name':'Atopica 10 mg, 15 Capsules ', 'category':'Sale/Pet Pharmacy/Allergy Relief', 'brand':'Novartis Animal Health', 'list':'Allergy Relief', 'position':1 });
ga('ec:addImpression', {'id':'1040389', 'name':'Prednisone 5 mg, 60 Tablets', 'category':'Sale/Pet Pharmacy/Allergy Relief', 'brand':'Generic Mfr', 'list':'Allergy Relief', 'position':41 });
ga('ec:addImpression', {'id':'1041407', 'name':'Temaril-P, 1 Tablet', 'category':'Sale/Pet Pharmacy/Allergy Relief', 'brand':'Zoetis', 'list':'Allergy Relief', 'position':42 });

ga('send', 'event', 'Impressions', 'Listing', 'Product Impression', 1, {'nonInteraction': 1, 'useBeacon': true } );

 

My question is - can I edit those somehow on the same page using javascript, after they are already called? I might need to change some values and add some custom fields, for example adding - 'isMedicine':'yes'

 

maybe using something like "editProduct" or whatever is available:

 

ga('ec:editProduct', {'id':'1010974', 'isMedicine':'yes', 'quantity': 3, 'name':'Atopica 10 mg, 15 Capsules ', 'category':'Allergy Medicine', 'brand':'Novartis Animal Health', 'variant':'', 'price':38.8300, 'quantity': 3 });

 

if there's not such a direct way through the API, can you suggest some javascript way of changing the data, without handling it server side?

 

Thanks!

Asaf

1 Expert replyverified_user

eCommerce tracking - editing added product

Top Contributor
# 2
Top Contributor

Hi you'll need to send subsequent GA calls with updated quantities/attributes.

VP & Chief Evangelist at Hub'Scan | Contact me
Level 80 Digital Analytics Warrior, KPI Therapist and Keeper of the One True Tagging Plan

eCommerce tracking - editing added product

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

ok then, say that this was the original call:

 

ga('ec:addProduct', {'id':'1010974', 'name':'Atopica 10 mg, 15 Capsules ', 'price':38.8300, 'quantity': 1 });

 

and after that i'm calling again just for changing quantities and adding a field (isMedicine) for the same cart item:

 

ga('ec:addProduct', {'id':'1010974', 'isMedicine':'yes', 'name':'Atopica 10 mg, 15 Capsules ', 'price':38.8300, 'quantity': 3 });

 

will it accept another call like that to update the same item in the cart? won't it just consider it as another different item to add?

eCommerce tracking - editing added product

Top Contributor
# 4
Top Contributor

Yes, just add another ec:addProduct call, attached to a page view or event.

GA will discriminate based on the product id/sku.

 

Also keep in mind you're just tracking an addToCart action, not tracking what's actually in the cart.

VP & Chief Evangelist at Hub'Scan | Contact me
Level 80 Digital Analytics Warrior, KPI Therapist and Keeper of the One True Tagging Plan