EduardET

avada script error

Jan 29th, 2018
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2. jQuery(function($) {
  3. tvc_lc="SGD";
  4.  
  5. homepage_json_ATC_link=[];
  6.  
  7. tvc_fp=[];
  8.  
  9. tvc_rcp=[];
  10.  
  11. tvc_rdp=[];
  12.  
  13. prodpage_json_ATC_link=[];
  14.  
  15. tvc_pgc=[];
  16.  
  17. catpage_json_ATC_link=[];
  18.  
  19.  
  20.                   ga("require", "ec", "ec.js");
  21.                   ga("set", "&cu", tvc_lc);
  22.         function t_products_impre_clicks(t_json_name,t_action){
  23.                    t_send_threshold=0;
  24.                    t_prod_pos=0;
  25.                    
  26.                     t_json_length=Object.keys(t_json_name).length;
  27.                        
  28.                     for(var t_item in t_json_name) {
  29.             t_send_threshold++;
  30.             t_prod_pos++;
  31.                            
  32.                  ga("ec:addImpression", {  
  33.                             "id": t_json_name[t_item].tvc_i,
  34.                             "name": t_json_name[t_item].tvc_n,
  35.                             "category": t_json_name[t_item].tvc_c,
  36.                             "price": t_json_name[t_item].tvc_p,
  37.                             "position": t_json_name[t_item].tvc_po,
  38.                         });
  39.                        
  40.         if(t_json_length > 6 ){
  41.                            if((t_send_threshold%6)==0){
  42.                             t_json_length=t_json_length-6;
  43.                             ga("send", "event", "Enhanced-Ecommerce","load","product_impression_"+t_action , {"nonInteraction": 1});  
  44.                         }
  45.                      }else{
  46.            
  47.                        t_json_length--;
  48.                        if(t_json_length==0){
  49.                         ga("send", "event", "Enhanced-Ecommerce","load", "product_impression_"+t_action, {"nonInteraction": 1});  
  50.                         }
  51.         }  
  52.                 }
  53.         }
  54.                
  55.         //function for comparing urls in json object
  56.         function prod_exists_in_JSON(t_url,t_json_name,t_action){
  57.                                     if(t_json_name.hasOwnProperty(t_url)){
  58.                                         t_call_fired=true;
  59.                     ga("ec:addProduct", {              
  60.                         "id": t_json_name[t_url].tvc_i,
  61.                                             "name": t_json_name[t_url].tvc_n,
  62.                                             "category": t_json_name[t_url].tvc_c,
  63.                                             "price": t_json_name[t_url].tvc_p,
  64.                                             "position": t_json_name[t_url].tvc_po,
  65.                     });
  66.                     ga("send", "event", "Enhanced-Ecommerce","click", "product_click_"+t_action, {"nonInteraction": 1});  
  67.                                    }else{
  68.                                    t_call_fired=false;
  69.                 }
  70.                                 return t_call_fired;
  71.             }
  72.                 function prod_ATC_link_exists(t_url,t_ATC_json_name,t_prod_data_json,t_qty){
  73.                     t_prod_url_key=t_ATC_json_name[t_url]["ATC-link"];
  74.                    
  75.                          if(t_prod_data_json.hasOwnProperty(t_prod_url_key)){
  76.                                 t_call_fired=true;
  77.                             // Enhanced E-commerce Add to cart clicks
  78.                               ga("ec:addProduct", {
  79.                                "id": t_prod_data_json[t_prod_url_key].tvc_i,
  80.                                "name": t_prod_data_json[t_prod_url_key].tvc_n,
  81.                                "category": t_prod_data_json[t_prod_url_key].tvc_c,
  82.                                "price": t_prod_data_json[t_prod_url_key].tvc_p,
  83.                                 "quantity" : t_qty
  84.                               });
  85.                               ga("ec:setAction", "add");
  86.                               ga("send", "event", "Enhanced-Ecommerce","click", "add_to_cart_click",{"nonInteraction": 1});    
  87.                               }else{
  88.                                    t_call_fired=false;
  89.         }    
  90.                          return t_call_fired;
  91.                  
  92.                 }
  93.                
  94.                
  95.                 if(tvc_fp.length !== 0){
  96.                     t_products_impre_clicks(tvc_fp,"fp");      
  97.                 }
  98.                 if(tvc_rcp.length !== 0){
  99.                     t_products_impre_clicks(tvc_rcp,"rp");    
  100.                 }
  101.                 jQuery("a:not([href*=add-to-cart],.product_type_variable, .product_type_grouped)").on("click",function(){
  102.             t_url=jQuery(this).attr("href");
  103.                         //home page call for click
  104.                         t_call_fired=prod_exists_in_JSON(t_url,tvc_fp,"fp");
  105.                         if(!t_call_fired){
  106.                             prod_exists_in_JSON(t_url,tvc_rcp,"rp");
  107.                         }    
  108.                 });
  109.                 //ATC click
  110.                 jQuery("a[href*=add-to-cart]").on("click",function(){
  111.             t_url=jQuery(this).attr("href");
  112.                         t_qty=$(this).parent().find("input[name=quantity]").val();
  113.                              //default quantity 1 if quantity box is not there            
  114.                             if(t_qty=="" || t_qty===undefined){
  115.                                 t_qty="1";
  116.                             }
  117.                         t_call_fired=prod_ATC_link_exists(t_url,homepage_json_ATC_link,tvc_fp,t_qty);
  118.                         if(!t_call_fired){
  119.                             prod_ATC_link_exists(t_url,homepage_json_ATC_link,tvc_rcp,t_qty);
  120.                         }
  121.                     });  
  122.              
  123.                
  124.  
  125. tvc_smd={"tvc_wcv":"3.2.6","tvc_wpv":"4.9.2","tvc_eev":"1.2.1.2","tvc_cnf":{"t_ee":"yes","t_df":false,"t_gUser":false,"t_UAen":"no","t_thr":"6"}};
  126.  });
  127. </script>
Advertisement
Add Comment
Please, Sign In to add comment