Hi Lamia,
In regard to the 1st question, I believe your best bet would be to include the utag.link call in the AJAX response returned from the server. Since the server call will contain the sku, you should be able to leverage that value in the utag.link call and the call will work. Without seeing the code though there isn't much more information that I can provide.
In regard to the 2nd question, Stefan is right that the for loop should use the less than sign, however I see some other issues that need to be fixed.
1) the utag_data object appears to try to use array values, but the syntax is incorrect. For example:
product_number: ["X1-38584,PA-23117"],
should be:
product_number: ["X1-38584","PA-23117"],
Notice how each item of the array is completely surrounded by double quotes, not just the beginning and end of the array
2) you need to declare product_sku_number as a string: b.product_sku_number="";
3) if you are joining multiple variables together you should check that they all exist before combining because if one of the variables does not exist then a JS error will be thrown.
if(b.product_sku && b.product_number){
4) There will always be a trailing comma with the code you have. I would add logic to remove the last comma:
b.product_sku_number=b.product_sku_number.replace(/,+$/, "");
So the final code is:
utag_data = {
site_region: "us",
site_currency: "usd",
page_name: "Cart",
page_type: "Cart",
product_number: ["X1-38584","PA-23117"],
product_id: ["100000041360","100000112977"],
product_sku: ["0038584664070","0023117009980"],
product_name: ["Joules Wellie","Cashel® Cool Crusader⠢ Standard Fly Mask with Ears"],
product_category: ["Riding Boots and Chaps","$50 & Under"],
product_subcategory: ["Wellies & Muck Boots","$10 - $25"],
product_brand: ["Joules","Cashel"],
product_list_price: ["69.99","23.99"],
product_sale_price: ["69.99","23.99"],
product_quantity: ["1","2"]
};
b.product_sku_number="";
if(b.product_sku && b.product_number){
for(i=0;i