Social widget with affiliate id

Created: 12/27/2016 | Updated: 8/24/2018 | Status: Published

when using the social widget you can send the affiliate id when the user click on the links inside the widget.

1. you can use the widget on your own domain, all you have to do is to add the a_aid parameter to the widget link

2. if you are using the widget on a different domain you will have to include these 2 scripts in your page in order it to work with the a_aid parameter.

 

<script type="text/javascript" src="http://d2vl6u6wrj3tgq.cloudfront.net/assets/v5/js/json2.js"></script>

<script type="text/javascript" src="http://d2vl6u6wrj3tgq.cloudfront.net/assets/v5/js/promos-cookies-1.js"></script>


E.G:
If one of your affiliate want to use the social widget on a different domain, lets say:
www.coollandingpage.com that means that other then using the parameter (in the above example) you also need to include the 2 mentioned scripts in the landing page code.
so the iframe url will be like this:


"http://widgets.yourdomain.com/widget/activity?numberOfRows=5&a_aid=123456789"

TIP:
your affiliate can hard code his a_aid in the code but he can also write a script that will fetch the a_id parameter from the landing page URL and will implement it in the social widget code.

here is  a simple example:

//getting all parameter and their values from the url:
(function (){
$.urlParam = function(name){
    var results = new RegExp('[\?&amp;]' + name + '=([^&amp;#]*)').exec(window.location.href);
    return results[1] || 0;
}
 

// example.com?param1=name&amp;a_aid=12345
//$.urlParam('param1'); // name
//$.urlParam('a_aid');        // 12345


 var affiliateId = $.urlParam('a_aid');

 //now we assign the parameter we got to the widget iframe url
 //lets say this is our iframe:
 // <iframe id="social-widget" src="http://widgets.tradesmarter.com/widget/activity?numberOfRows=5" width="296" //height="298" ></iframe>

 
 var _src = $("#social-widget").attr("src");
$("#social-widget").attr("src", src + affiliateId);

})();