Expand my Community achievements bar.

SOLVED

s.products replace item

Avatar

Level 3

Hi,

I'm having difficulties in planning out the code needed for my s.product rule and I wondered if anyone could help.

We basically have a shopping cart where you can add a product. However once added you cannot remove the product but only replace with another product.

What would be the best way of running the code for this scenario?

My thoughts are:

product added : scAdd

product replaced : scRemove,scAdd

The part i'm not sure about is the product replace, would using scRemove and scAdd in a single Adobe call remove the original product and replace with new work ok?

or

Will I have to fire two separate Adobe calls, one for scRemove and another for scAdd?

Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 9

The e-commerce events act globally on all products listed in the products variable, so if you have e.g.

s.events="scRemove,scAdd";

s.products=";sku1,;sku2";

Adobe Analytics will record a scRemove and scAdd event for both products.  So, if you have an existing product (sku1) you already previously added (scAdd) and want to remove it (scRemove) and then add (scAdd) another product (sku1), you will need to make two separate AA calls to accomplish this.

Example:

Original scAdd call (for context):

s.events = "scAdd";

s.products = ";sku1";

s.linkTrackVars="scAdd,events,products";

s.linkTrackEvents="scAdd";

s.tl(true,"o","cart add");

First, remove product sku1:

s.events = "scRemove";

s.products = ";sku1";

s.linkTrackVars="scRemove,events,products";

s.linkTrackEvents="scRemove";

s.tl(true,"o","cart remove");

Then, add the new product sku2:

s.events = "scAdd";

s.products = ";sku2";

s.linkTrackVars="scAdd,events,products";

s.linkTrackEvents="scAdd";

s.tl(true,"o","cart add");

View solution in original post

1 Reply

Avatar

Correct answer by
Level 9

The e-commerce events act globally on all products listed in the products variable, so if you have e.g.

s.events="scRemove,scAdd";

s.products=";sku1,;sku2";

Adobe Analytics will record a scRemove and scAdd event for both products.  So, if you have an existing product (sku1) you already previously added (scAdd) and want to remove it (scRemove) and then add (scAdd) another product (sku1), you will need to make two separate AA calls to accomplish this.

Example:

Original scAdd call (for context):

s.events = "scAdd";

s.products = ";sku1";

s.linkTrackVars="scAdd,events,products";

s.linkTrackEvents="scAdd";

s.tl(true,"o","cart add");

First, remove product sku1:

s.events = "scRemove";

s.products = ";sku1";

s.linkTrackVars="scRemove,events,products";

s.linkTrackEvents="scRemove";

s.tl(true,"o","cart remove");

Then, add the new product sku2:

s.events = "scAdd";

s.products = ";sku2";

s.linkTrackVars="scAdd,events,products";

s.linkTrackEvents="scAdd";

s.tl(true,"o","cart add");