parameter a_aid di halaman arahan

Created: 4/13/2016 | Updated: 8/23/2018 | Status: Published


extraction url parameters and adding the to the registration widget to associate affiliate id with a user


1. your main goal is to get the affiliate id and add it to the registration widgets, so the final result will be:

<iframe id="registration-widget" src="http://widgets.tradesmarter.com/widget/registration?a_aid=123456789" style="width: 310px; height: 591px; border:0; border-radius: 10px;"></iframe>

2. in order to achieve this you need to add a script that will get the url parameter from the page,
you can use something like this,
lest say the current url is: www.my-landing-page.com?affiliate=123456789

Add this script to the bottom of your page:

<script>
$(document).ready(function(){
 function getUrlParameter(sParam)
            {    
                   var sPageURL = window.location.search.substring(1);
                    var sURLVariables = sPageURL.split('&');
                        for (var i = 0; i < sURLVariables.length; i++)
                        {
                            var sParameterName = sURLVariables[i].split('=');
                                if (sParameterName[0] == sParam)
                                        {
                                        return sParameterName[1];
                                        }
                        }
                }
        var a_aid = getUrlParameter('affiliate');
        var _src = jQuery("#registration-widget").attr("src");
        jQuery("#registration-widget").attr("src", _src + 'a_aid=' + a_aid);
}):
</script>


the script will:
A. retrieve the "affiliate" parameter value
B. save it to a variable called a_aid
C. change the registration widget iframe url by adding the a_aid parameter with the value retrieved from the "affiliate" parameter in the url of your page.
 

lets put it all together:


1. we are in a landing page with this url:
www.my-landing-page.com?affiliate=123456789

2. the script will change the registration widget SRC attribute from this:
http://widgets.tradesmarter.com/widget/registration?
to this:
http://widgets.tradesmarter.com/widget/registration?a_aid=123456789

3. when user will register the affiliate id will be shown in the back office

<iframe id="registration-widget" src="http://widgets.tradesmarter.com/widget/registration?" style="width: 310px; height: 591px; border:0; border-radius: 10px;"></iframe>