Expand my Community achievements bar.

SOLVED

Purchase Event Rule

Avatar

Level 4

I have created purchase event rule by using direct call identifier, but here I am facing issue regarding setting variables i.e. event is firing but product variable is not setting. Please see the screenshot for the same:

 

bindukumari1990_0-1625994339717.png

bindukumari1990_1-1625994387186.png

So, please let know the reason for the same.

 

Thanks!!

 

 

1 Accepted Solution

Avatar

Correct answer by
Level 7

@bindukumari1990  If this is an s.tl() call than s.products needs to be passed in s.linkTrackVars as per the given below document in the custom code editor in Launch rule :-

https://experienceleague.adobe.com/docs/analytics/implementation/vars/config-vars/linktrackvars.html...

View solution in original post

5 Replies

Avatar

Correct answer by
Level 7

@bindukumari1990  If this is an s.tl() call than s.products needs to be passed in s.linkTrackVars as per the given below document in the custom code editor in Launch rule :-

https://experienceleague.adobe.com/docs/analytics/implementation/vars/config-vars/linktrackvars.html...

Avatar

Level 4

@amgup, Okay I have added, but without s.tl() call, direct call identifier is triggered, even I can see rule is firing in the dtm switch extension, but still variables are not setting. Any specific reason?

Avatar

Level 7
Can you share the screenshot of products syntax you have set in your code ?

Avatar

Level 4

@amgup, Please find the code below:

 

s.products = "";
s.eVar14 = "";
//s.eVar17 = "";
for(var i=0; i<window.shopti_data_layer.products.length; i++) {
//
s.linkTrackVars = "eVar10,eVar12,eVar14,eVar15,eVar16,eVar17,products";
//s.eVar14 = window.shopti_data_layer.products[i].product_id ;
s.eVar10 = window.shopti_data_layer.cart_total;
s.eVar12 = window.shopti_data_layer.total_products;


s.products += window.shopti_data_layer.products[i].product_category + ";" + window.shopti_data_layer.products[i].name.replace(/,/g, "") + ";" + window.shopti_data_layer.product_qty[i] + ";" + window.shopti_data_layer.product_qty[i] * window.shopti_data_layer.product_prices[i] + ";" + ";" + "eVar14=" + window.shopti_data_layer.products[i].product_id + "|" + "eVar16=" + window.shopti_data_layer.products[i].product_category + "|" + "eVar17=" + window.shopti_data_layer.products[i].product_sub_category;
if(i != window.shopti_data_layer.products.length-1) {
s.products += ",";

}
}

s.eVar10 ="";
s.eVar12 ="";
s.eVar14 = "";
s.eVar15 = "";
//s.eVar16 = "";
//s.eVar17 = "";
for(var i=0; i<window.shopti_data_layer.products.length; i++) {

//s.eVar14 += window.shopti_data_layer.products[i].product_id ;
//s.eVar15 += window.shopti_data_layer.products[i].name.replace(/,/g, "") ;
s.eVar10 = window.shopti_data_layer.cart_total;
s.eVar12 = window.shopti_data_layer.total_products;
//s.eVar16 += window.shopti_data_layer.products[i].product_category ;
//s.eVar17 += window.shopti_data_layer.products[i].product_sub_category;
if(i != window.shopti_data_layer.products.length-1) {
// s.eVar14 += ",";
//s.eVar15 += ",";
//s.eVar16 += ",";
//s.eVar17 += ",";
}
}

 

 

 

/*var input = s.products;
var fields = input.split(';');
for(var j =0; j< fields.length;j++){
if(fields[j] != 'undefinedundefined' || fields[j] != 'undefined'){
s.products += fields[j];
}
}*/

Avatar

Level 7
There seems to be some syntax related issue. I will suggest you to breakdown this syntax in simple terms. Also remove the '+' after the s.products.