Expand my Community achievements bar.

Join us January 15th for an AMA with Champion Achaia Walton, who will be talking about her article on Event-Based Reporting and Measuring Content Groups!
SOLVED

Classification in eVar

Avatar

Level 4

Hi Team,

 

I am using s.product string to capture the product details. I am capturing the primary category in evar16 and 17. I am using the below code to capture the data:

 

bindukumari1990_1-1621332386096.png

 

So, now if multiple product is added in the cart, then multiple values in coming in the report, so can I resolve the issue through classification.

bindukumari1990_0-1621331770209.png

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor and Adobe Champion

Dear Bindu,

Sorry, Classification is not the solution for your use case.

Guess, rather than capturing the products in the syntax below

s.products = "Category1;Product1;;;;eVar14=Value1|eVar17=Value1,Category2;Product2;;;;eVar14=Value2|eVar17=Value2,Category3;Product3;;;;eVar14=Value3|eVar17=Value3,";

you are capturing it as

s.products = "Category1,Category2,Category3;Product1,Product2,Product3;;;;eVar14=Value1,Value2,Value3|eVar17=Value1,Value2,Value3";

So, you need to have a proper syntax on your product string and that will resolve your issue.

Thank You, Pratheep Arun Raj B | Xerago | Terryn Winter Analytics

PS: I have bolded few values so that you can understand the difference due to multiple products.

View solution in original post

17 Replies

Avatar

Community Advisor

I think your code is wrong.

You're resetting s.products with each item in your shopti_data_layer's products array. What you should be doing is to append each item to s.products.

So something like this:

s.products = "";
for (var i=0; i < window.shopti_data_layer.products.length; i++) {
  var product = window.shopti_data_layer.products[i].category + ";" + [rest of the product's data and eVars to be tracked];
  s.products = s.apl(s.products, product);
}

Avatar

Level 4
@yuhuisg, it is not resetting basically, when user is adding multiple products in cart, then evar16 and evar17 is storing multiple categories in it. how we can avoid this?

Avatar

Community Advisor
You're right, I misread your code and missed out that you're using "s.products += ...". I had read it as "s.products = ...".

Avatar

Community Advisor
Can you copy-paste the full code? Your screenshot cuts off at the right part after "s.eVar14 = ", so it's not possible to troubleshoot.

Avatar

Level 4

@yuhuisg

s.products = "";
s.eVar14 = "";
s.eVar17 = "";
for(var i=0; i<window.shopti_data_layer.products.length; i++) {
//
s.linkTrackVars = "eVar14,eVar15,eVar16,eVar17";
s.eVar14 = window.shopti_data_layer.products[i].product_id ;
s.eVar17 = window.shopti_data_layer.products[i].product_sub_category;
//s.eVar15 += window.shopti_data_layer.products[i].name ;
//s.eVar15 = window.shopti_data_layer.products[i].name ;
//s.eVar16 = window.shopti_data_layer.products[i].product_category ;
// Add individual produ ct info to the product string
//s.products += window.shopti_data_layer.products[i].product_category + ";" + window.shopti_data_layer.products[i].name + ";" + ";" + ";" + ";" +s.eVar14 ;
s.products += window.shopti_data_layer.products[i].product_category + ";" + window.shopti_data_layer.products[i].name.replace(/,/g, "") + ";" + ";" + ";" + ";" + "eVar14=" + s.eVar14 + "|" + "eVar17=" + s.eVar17;
if(i != window.shopti_data_layer.products.length-1) {
s.products += ",";

}
}

Hope it s fine.

Avatar

Community Advisor
@bindukumari1990 I don't see eVar16 being set in this code that you pasted here. Can you please verify that you've provided the actual code? It will be difficult to troubleshoot if you're not providing the code that is producing the resulting data in AA.

Avatar

Employee Advisor

Yes you can use classification to resolve this.

Avatar

Community Advisor
Which eVar does your freeform table screenshot refer to?

Avatar

Correct answer by
Community Advisor and Adobe Champion

Dear Bindu,

Sorry, Classification is not the solution for your use case.

Guess, rather than capturing the products in the syntax below

s.products = "Category1;Product1;;;;eVar14=Value1|eVar17=Value1,Category2;Product2;;;;eVar14=Value2|eVar17=Value2,Category3;Product3;;;;eVar14=Value3|eVar17=Value3,";

you are capturing it as

s.products = "Category1,Category2,Category3;Product1,Product2,Product3;;;;eVar14=Value1,Value2,Value3|eVar17=Value1,Value2,Value3";

So, you need to have a proper syntax on your product string and that will resolve your issue.

Thank You, Pratheep Arun Raj B | Xerago | Terryn Winter Analytics

PS: I have bolded few values so that you can understand the difference due to multiple products.

Avatar

Level 3
@PratheepArunRaj but I am using data layer to populate the same, then how can I use the above syntax, can you give me working example.

Avatar

Community Advisor and Adobe Champion
Dear Bindu, Really sorry. I am not a developer and thus it is tougher for me to give you the exact code. Based on the screenshot you have provided, I can see that multiple values are in the eVar with delimiter ',' and thus guessed it for the syntax. Thank You, Pratheep Arun Raj B

Avatar

Community Advisor and Adobe Champion

Dear Bindu, Quick gotcha. Can you change the variable declaration for s.eVar14 and s.eVar17 to something else?

From

s.eVar14 = window.shopti_data_layer.products[i].product_id ;
s.eVar17 = window.shopti_data_layer.products[i].product_sub_category;

To

var Var14 = window.shopti_data_layer.products[i].product_id ;
var Var17 = window.shopti_data_layer.products[i].product_sub_category;

And then the product string to

s.products += window.shopti_data_layer.products[i].product_category + ";" + window.shopti_data_layer.products[i].name.replace(/,/g, "") + ";" + ";" + ";" + ";" + "eVar14=" + Var14 + "|" + "eVar17=" + Var17;

Guess, s.eVar14 and s.eVar17 are set twice, once in global & another in merchandising and thus the issue. Just a thought!

Thank You, Pratheep Arun Raj B

Avatar

Level 3
@PratheepArunRaj Yes, I understood the reason. It is because I am initializing the value at top. Need to add in the s.product string.

Avatar

Community Advisor and Adobe Champion
Dear Bindu, Are you able to fix it? Thank You, Pratheep Arun Raj

Avatar

Community Advisor and Adobe Champion
Oh! Great to hear. Thanks, Pratheep Arun Raj B