To integrate your Shopify store, you can use the official built-in plugin but first you need to create a private app in your Shopify store.



1. Login to your Shopify admin panel and navigate to Apps> Manage private apps (a link at the bottom)

2. Create a new private app

3. Name the app as you like, you can add your email address to be notified in case of problems, then you need to scroll down and click on disabled permissions and search for Script tags in your store's theme template files and change the permission to Read and write. Do not change anything else and save the app


4. Once the app is created you'd need the API key, Password and your store's URL address

5. Now you need to navigate to your Post Affiliate Pro merchant panel and to Configuration->Plugins section

6. You need to find the Shopify API and notification handling plugin and activate it.

7. Once activated you need to click on Configure next to it and enter your store URL, api key and password and configure how you want the integration to behave.

8. Save the configuration and if no error pops up you are done and your site should start tracking.













If, for some reason, you cannot use the plugin and you want to integrate your Shopify site manually, you can use the following steps.

1.

Login and navigation

Login to your admin panel. Navigate to Settings> Checkout and scroll down to Additional Content & Scripts in the section Order processing.

2.

Code

The sale tracking code to track one commission per order is this:

<script id="pap_x2s6df8d" src="http://URL_TO_PostAffiliatePro/scripts/trackjs.js" type="text/javascript"></script>
<script type="text/javascript">
	if (window.location.href.indexOf('/thank_you') > 0) {
		PostAffTracker.setAccountId('Account_ID');
		var sale = PostAffTracker.createSale();
		sale.setTotalCost('{{subtotal_price | money_without_currency | replace: ',', '' }}');
		sale.setOrderID('{{order_number}}');
		sale.setProductID('{{product_ids}}');
	
		PostAffTracker.register();
	}
</script>

And now just save it and you are ready to track the sales now.

If you would want to use also Lifetime Commissions plugin you need to add the following line to right under sale.setProductID('{{product_ids}}'); to add the customer's email address to the order:
sale.setData1(Shopify.checkout.email);

Or you can use customer ID instead of email, to keep it private:

sale.setData1(Shopify.checkout.customer_id);

3.

Per product integration

In case you want to track per product commissions, you should use this integration code instead of the one from step 2.

<script id="pap_x2s6df8d" src="http://URL_TO_PostAffiliatePro/scripts/trackjs.js" type="text/javascript"></script>
<script type="text/javascript">
if (window.location.href.indexOf('/thank_you') > 0) {
PostAffTracker.setAccountId('Account_ID');
  var discount = '';
  var discountedperc = 1;
  {% for discount in order.discount_applications %}
    discount = '{{ discount.title }}';
    if ('{{discount.target_type}}' == 'line_item') {
        discountedperc = {{ discount.value | money_without_currency | replace: ',', '' }};
	if ({{ discount.value_type == 'fixed_amount') {
    	discountedperc = 1 - {{ discount.value | money_without_currency | replace: ',', '' }} / ({{ order.subtotal_price | money_without_currency | replace: ',', '' }} + {{ discount.amount | money_without_currency | replace: ',', '' }});
	}
    }
  {% endfor %}

{% for line_item in line_items %}
  var price = {{ line_item.final_line_price | money_without_currency | replace: ',', '' }} * discountedperc;
  var sale{{ forloop.index }} = PostAffTracker.createSale();
  sale{{ forloop.index }}.setTotalCost(price);
  sale{{ forloop.index }}.setOrderID('{{order_number}}({{ forloop.index }})');
  sale{{ forloop.index }}.setProductID('{{ line_item.sku }}');
  sale{{ forloop.index }}.setCoupon(discount);
{% endfor %}

PostAffTracker.register();
}
</script>

You are done, this is all needed. Save your changes and you are ready to use the integration.

If you would want to use also Lifetime Commissions plugin you need to add the following line to right under sale{{forloop.index}}.setCoupon(discount); to add the customer's email address to the order.

sale{{forloop.index}}.setData1(Shopify.checkout.email);


Additional info can be found here:

https://docs.shopify.com/themes/liquid/objects/order

Do not forget to integrate your shop with the click tracking code.

You can insert it into the theme of your store this way: 

Online store> Themes> Customize theme (top right corner)> Theme option (top left corner)> Edit HTML/CSS

In 'Layout' directory, there is a file called 'theme/liquid'. Insert the click tracking code right above </BODY> tag in that file and save it.