Installation Guide

1. Install Social Analytics code

Copy and paste into the global footer template:

<script type="text/javascript">
var js = document.createElement('script'); js.type = 'text/javascript'; js.async = true; js.id = 'AddShoppers';
js.src = ('https:' == document.location.protocol ? 'https://shop.pe/widget/' : 'http://cdn.shop.pe/widget/') + 'widget_async.js#XXXXX';
document.getElementsByTagName("head")[0].appendChild(js);
</script>

2. Install ROI Tracking code

1. go to shopify admin, on the left go to settings -> checkout >> scroll down to "order processing" 
and paste the code below at the bottom of the "additional content & scripts" section: http://prntscr.com/6hlai8

2. code to paste (Note relace XXXXXXX in the code below with your AddShoppers Shop ID: 

<!-- AddShoppers ROI Tracking Start -->
<script type="text/javascript">
AddShoppersConversion = {
        order_id: '{{ order_number }}',
        value: '{{ total_price | money_without_currency }}'
};
var js = document.createElement('script'); js.type = 'text/javascript'; js.async = true; js.id = 'AddShoppers';
js.src = ('https:' == document.location.protocol ? 'https://shop.pe/widget/' : 'http://cdn.shop.pe/widget/') + 'widget_async.js#XXXXXX';
document.getElementsByTagName("head")[0].appendChild(js);
</script>
<!-- AddShoppers ROI Tracking End -->

3. Add sharing buttons

How To Open The Sharing Panel With Custom Buttons or Text

If you want to open our sharing panel with anything else that isn't one of our buttons (a text link, your own sharing buttons, or anything else), you can do so by calling the Social method of our Javascript API in one of 3 ways (the network in quotes sets the network that will be shown first when the panel is opened):
AddShoppersWidget.API.Social.app('facebook')
AddShoppersWidget.API.Social.app('twitter')
AddShoppersWidget.API.Social.app('email')
Just choose the network that you want to be shown first (Facebook, Twitter, or Email) and call that function to open the sharing panel.
Here's the code for an example text link that will open up the panel, defaulting to Facebook:
<a href="#" onclick="AddShoppersWidget.API.Social.app('facebook'); return false;">Share and save!</a>
Here's an example for custom Facebook and Twitter buttons:
<a href="#" onclick="AddShoppersWidget.API.Social.app('facebook'); return false;"><img src="URL TO YOUR FACEBOOK BUTTON IMAGE HERE" ></a>

<a href="#" onclick="AddShoppersWidget.API.Social.app('twitter'); return false;"><img src="URL TO YOUR TWITTER BUTTON IMAGE HERE" ></a>
Just make sure that you're also including the Social Analytics code or else it won't work!

4. Social Login Installation

a. Please email mario@addshoppers.com for the final setup in this step, he will need API credentials for your Shopify account.

b. NOTE** In the JS of the code there is a part of the url called "YOURSTORE" please replace this with the folder name you get from Mario in part a.

<form accept-charset="UTF-8" action="/account/login" id="aslcustomer_login" method="post" style="display: none !important;"><input name="form_type" type="hidden" value="customer_login" /> <input name="utf8" type="hidden" value="✓" /> <input type="email" value="" name="customer[email]" id="aslEmail" class="form-control" placeholder="Email" /> <input type="password" value="" name="customer[password]" id="aslPass" class="form-control" placeholder="Passsword" /> <input class="btn btn-primary1 btn btn-primary btn-lg" type="submit" value="Sign In" /></form>

<script type="text/javascript">
// Init code          
function init() {
   AddShoppersWidget.API.Event.bind("sign_in", createAccount);    
};
// Create Account 
function createAccount(params) {    
   if (params.source == "social_login") {       
    services = ['facebook', 'google', 'linkedin', 'twitter', 'paypal'];
    var data = AddShoppersWidget.API.User.signed_data(); 
    for( var i=0; i < services.length; i++ ) {        
      service = services[i];
      if (AddShoppersWidget.API.User.signed(service)) {
            var email = data[service + '_email'];
            if (service == 'twitter') {
                //alert('popup get email'); 
                var email = prompt("Please enter your email", "");
            };
            if (email) {
                if (service !='twitter' ) {          
                  var name = data[service + '_firstname'] + '_' + data[service + '_lastname']; 
                } else {
                var name = data[service + '_name']; 
                };
            //name = name.replace(/ /g, '-');
                    name = name.replace("_", " ");
                    var asFName = name.substr(0,name.indexOf(' '));
                    var asLname = name.substr(name.indexOf(' ')+1);

            console.log("data: "+ data.signature);
                               console.log("First: "+ asFName +" Last: "+ asLname);
                  var asSocialMail = email;
                  var asSocialGenPass = "";
                  
                  //console.log(asFName + asLname + asSocialMail + asSocialGenPass );
                  console.log("submitting");

                  $.ajax({
                        type: "GET",
                        url: "https://i.addshoppers.com/merchants/YOURSTORE/socialLogin/customer.php",
                        data: { data: data,email: asSocialMail },
                        success: function (data) {
                                //console.log(data);
                                if(data == "false"){
                                    console.log('failboat');
                                } else {
                                    asSocialGenPass = data;
                                    asSocialGenPass = asSocialGenPass.replace("true|","");
                                    console.log(asSocialGenPass);


                                    //try to login
                                    document.getElementById('aslEmail').value = asSocialMail;
                                    document.getElementById('aslPass').value = asSocialGenPass;
                                    jQuery('#aslcustomer_login').submit();
                                }
                        }
                  });
              break; 
            };
        }; 
      };  
    };        
}
          
// Bind events
if (window.addEventListener) {      
   window.addEventListener("load", init, false); 
} else {
   document.onreadystatechange = function() { 
    if(document.readyState in {loaded: 1, complete: 1}) {
  document.onreadystatechange = null; 
       init();      
    } 
  }         
} 


//inline ajax form submit LOGIN
var $formLOG = $('#aslcustomer_login');
$formLOG.submit(function(){
$.post($(this).attr('action'), $(this).serialize(), function(response){
// do nothing
},'json');
return false;
});
</script>