capture products array in checkout page | Community
Skip to main content
New Participant
May 22, 2018

capture products array in checkout page

  • May 22, 2018
  • 3 replies
  • 10732 views

Hi, I am trying to capture product name and SKU of all the products that added to cart on the checkout page. how to set up data elements and rule in Adobe Launch? I assume it may require custom code? Does anyone know?

SC

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

Stewart_Schilling
New Participant
May 23, 2018

Then in the AA custom code of your cart view rule, you'd set s.products as such:

s.products = _satellite.getVar("_your data element here_");

It's worth noting that since you presently cannot set s.products from anywhere except in AA custom code, you _could_ just use the code above and set s.products directly instead of using a data element.

Stewart_Schilling
New Participant
May 23, 2018

Much of the code is just for exposition (to explain what I'm doing).

For your data element, you'd paste just this much and add a return line as such:

var cartItemCount = window.digitalData.cart.item.length||0;

var productStanzas=[];

for (var i=0; i<cartItemCount; i++) {

  var cartItem = window.digitalData.cart.item[i].productInfo;

  var stanza=[];

  stanza[0] = ""; //empty Catgeory

  stanza[1] = cartItem.productID;

  stanza[2] = ""; //empty quantity

  stanza[3] = ""; //empty unit price

  stanza[4] = ""; //empty product level events

  var stanzaEvars=[];

  stanzaEvars.push("eVar2="+cartItem.productName);

  stanzaEvars.push("eVar3="+cartItem.productstyleNumber);

  stanzaEvars.push("eVar4="+cartItem.productID);

  stanzaEvars.push("eVar5="+cartItem.productCategory);

  stanza[5] = stanzaEvars.join("|");

  productStanzas.push(stanza.join(";"));

}

var productString = productStanzas.join(",");

return productString;

Stewart_Schilling
New Participant
May 23, 2018

Yes. I have done this too many times to count.

Custom JS is probably required.

To be more helpful, can you answer a couple questions?

1) Do you know where the cart item data exists on the page?

2) Are you lucky enough to have this data in a data layer that can be easily accessed from JavaScript?

3) What do you want to do with this data (include in an Adobe Analytics beacon? Populate a 3rd Party Tag? Other?)

New Participant
May 23, 2018

Hi Stewart,

Please see my answers below-

1)2) I have all the product infor (name, sku, category) in a data layer and can access from JacaScript.

3) I include this data in an Adobe Analytics beacn.

Stewart_Schilling
New Participant
May 23, 2018

Would you mind providing an example of the data layer JSON object?

Would you mind providing the AA requirements? events, and evars

With this, I can get you pointed in the right direction.