Problems in goal tracking in Shopify thank you page and cloaked links

I sell a few products on Shopify and want to track purchases as goal conversions with a value.
I have added piwik code in the thank you page and it’s not tracking the conversions.

I have also the same problem with some wordpress sites where i redirect urls and try to track conversion.
So guy clicks link and then it’s redirected to an affiliate link.I have the piwik code on the middle page.

Anybody have similar issues? How to fix it? Thanks!

This is the code I use for shopify

var _paq = _paq || [];
_paq.push([‘trackGoal’, 4, {{ total_price | money_without_currency }}]);
(function() {
var u="//";
_paq.push([‘setTrackerUrl’, u+‘piwik.php’]);
_paq.push([‘setSiteId’, ‘2’]);
var d=document, g=d.createElement(‘script’), s=d.getElementsByTagName(‘script’)[0];
g.type=‘text/javascript’; g.async=true; g.defer=true; g.src=u+‘piwik.js’; s.parentNode.insertBefore(g,s);