Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
integration:googleanalytics_universal [2014/04/24 16:02] – [Testing] align right sparkwebintegration:googleanalytics_universal [2021/09/10 09:31] (current) – [Setting Up Your Site] adam
Line 17: Line 17:
 <WRAP center round important 80%> <WRAP center round important 80%>
 These instructions are new, and while we have done some testing on the set up - the following are new instructions. Where possible we recommend testing this set up on a test profile before setting to your live analytics account, to ensure it works perfectly for your store. Any questions or issues, please get in touch with us. These instructions are new, and while we have done some testing on the set up - the following are new instructions. Where possible we recommend testing this set up on a test profile before setting to your live analytics account, to ensure it works perfectly for your store. Any questions or issues, please get in touch with us.
 +</WRAP>
 +
 +<WRAP center round info 80%>
 +**Using FoxyCart 2.0?** Google Analytics is now a configuration option within your store's administration. Take a look at [[v:2.0:analytics|Store Analytics]] for more information.
 </WRAP> </WRAP>
  
Line 57: Line 61:
   - Under 'Tracking Info' click 'Referral Exclusion List'. By default, your own website's domain should be present here, but we will need to add your store domain.   - Under 'Tracking Info' click 'Referral Exclusion List'. By default, your own website's domain should be present here, but we will need to add your store domain.
   - Click 'Add Referral Exclusion' and enter your store domain, such as "mystore.foxycart.com", and click "Create".   - Click 'Add Referral Exclusion' and enter your store domain, such as "mystore.foxycart.com", and click "Create".
 +  - If your own website domain isn't present in that list - add it as well.
   - Proceed to the next section   - Proceed to the next section
  
Line 128: Line 133:
 Proceed to the next section. Proceed to the next section.
 ===== Setting Up Your Site ===== ===== Setting Up Your Site =====
-  - On your own site, add the following to each page (except your FoxyCart cart, checkout and receipt templates), right before the closing ''</head>'' tag - ensuring that it's included **after** the foxycart.js file you copied from the Sample Code section of your stores FoxyCart administration:<code javascript><script>+  - On your own site, add the following to each page (except your FoxyCart cart, checkout and receipt templates), right before the closing ''</head>'' tag - ensuring that it's included **after** the foxycart.js file you copied from the Sample Code section of your stores FoxyCart administration. <wrap hi>Also, make sure you update the ''UA-XXXX-Y'' with your correct Analytics account identifier</wrap>:<code javascript><script>
   (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){   (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
   (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),   (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
Line 139: Line 144:
 </script> </script>
 <script type="text/javascript" charset="utf-8"> <script type="text/javascript" charset="utf-8">
-  fcc.events.cart.preprocess.add(function(e, arr) { +    fcc.events.cart.preprocess.add(function (e, arr) { 
-    if (arr['cart'] == 'checkout' || arr['cart'] == 'updateinfo' || arr['output'] == 'json') { +        if (arr['cart'] == 'checkout' || arr['cart'] == 'updateinfo' || arr['output'] == 'json') { 
-      return true; +            return true; 
-    +        
-    if (arr['cart'] == 'checkout_paypal_express') { +        if (arr['cart'] == 'checkout_paypal_express') { 
-      ga('send', 'pageview', '/paypal_checkout',+            if (window.ga && ga.loaded) { 
-        'hitCallback': function() { +                ga('send', 'pageview', '/paypal_checkout',
-          jQuery.getJSON('https://' + document.domain + '/cart?' + fcc.session_get() + '&h:_fcpm=paypal|cart&output=json&callback=?', function(cart) { +                    'hitCallback': function () { 
-            fcc.events.cart.preprocess.resume(); +                        jQuery.getJSON('https://' + document.domain + '/cart?' + fcc.session_get() + '&h:_fcpm=paypal|cart&output=json&callback=?', function (cart) { 
-          });+                            fcc.events.cart.preprocess.resume(); 
 +                        })
 +                    } 
 +                }); 
 +                return "pause"; 
 +            } else { 
 +                return true; 
 +            } 
 +        } 
 +        return true; 
 +    }); 
 +    //CAUSING LOOPING ISSUES IN CHROME 
 +    fcc.events.cart.process.add_pre(function (e, arr) { 
 +        if (window.ga && ga.loaded) { 
 +            ga(function (tracker) { 
 +                jQuery.getJSON('https://' + storedomain + '/cart?' + fcc.session_get() + '&h:ga=' + escape(tracker.get('clientId')) + '&output=json&callback=?', function (data) { 
 +                    fcc.events.cart.process.resume(); 
 +                }); 
 +            }); 
 +            return "pause"; 
 +        } else { 
 +            return true;
         }         }
-      }); 
-      return "pause"; 
-    } 
-    return true; 
-  }); 
-  fcc.events.cart.process.add_pre(function(e, arr) { 
-    ga(function(tracker) { 
-      jQuery.getJSON('https://' + storedomain + '/cart?' + fcc.session_get() + '&h:ga=' + escape(tracker.get('clientId')) + '&output=json&callback=?', function(data){ 
-        fcc.events.cart.process.resume(); 
-      }); 
     });     });
-    return "pause"; 
-  }); 
 </script></code> </script></code>
  
Line 171: Line 185:
  
 ===== Setting Up Your FoxyCart Templates, The Full Details ===== ===== Setting Up Your FoxyCart Templates, The Full Details =====
-Copy the following and paste it above the closing ''</head>'' tag in the respective templates. This can be directly in your [[https://admin.foxycart.com/|FoxyCart admin]] or (preferably) in a template on your server that you will load into FoxyCart via FoxyCart's template caching functionality+Copy the following and paste it above the closing ''</head>'' tag in the respective templates. This can be directly in your [[https://admin.foxycart.com/|FoxyCart admin]] or (preferably) in a template on your server that you will load into FoxyCart via FoxyCart's template caching functionality. <wrap hi>Again, make sure you update the ''UA-XXXX-Y'' with your correct Analytics account identifier.</wrap>
  
 === The Cart Template === === The Cart Template ===
Line 194: Line 208:
     }     }
     $('a.fc_cart_checkout_paypal').click(function(e){     $('a.fc_cart_checkout_paypal').click(function(e){
-      e.preventDefault(); +      if (window.ga && ga.loaded) 
-      var link_url = jQuery(this).attr("href"); +        e.preventDefault(); 
-      var gateway = (jQuery(this).hasClass("fc_cart_checkout_amazon")) ? "amazon_fps" : "paypal"; +        var link_url = jQuery(this).attr("href"); 
-      ga('send', 'pageview', '/' + gateway + '_checkout',+        var gateway = (jQuery(this).hasClass("fc_cart_checkout_amazon")) ? "amazon_fps" : "paypal"; 
-        'hitCallback': function() { +        ga('send', 'pageview', '/' + gateway + '_checkout',
-          $form = jQuery('<form method="post" target="_top"></form>').attr("action", link_url).appendTo("body"); +          'hitCallback': function() { 
-          jQuery.getJSON('https://' + document.domain + '/cart?fcsid=' + jQuery("input[name='fcsid']").first().val() + '&h:_fcpm=' + gateway + '|cart&output=json&callback=?', function(cart) { +            $form = jQuery('<form method="post" target="_top"></form>').attr("action", link_url).appendTo("body"); 
-            $form.submit(); +            jQuery.getJSON('https://' + document.domain + '/cart?fcsid=' + jQuery("input[name='fcsid']").first().val() + '&h:_fcpm=' + gateway + '|cart&output=json&callback=?', function(cart) { 
-          }); +              $form.submit(); 
-        +            }); 
-      });+          
 +        }); 
 +      }
     });     });
   });   });

Site Tools