How to make a referral url get injected to opt in form?

by jdem02
13 replies
Hey guys,
Got a question.
I want to start an affiliate site but I want to I guess you would call inject certain variables into a opt in form so when a person opt ins it goes to that affiliate. So say the url is yourwebite.com/?ref=ixxx&fid=xxxx0&cc=exxxx I need these 3 variables passed to the opt in form. I've spent a few days trying to figure out how to do this. Anyone help please?
#form #injected #make #opt #referral #url
  • Profile picture of the author Andrew H
    <?php

    //grab the affilliate id from the url
    // yourwebsite.com?id=123
    $id = $_GET['id'];

    ?>

    <form>
    //place your other form fields here
    <input type="hidden" name="affiliateid" value="<?php echo $id; ?>">
    </form>

    A variable stored in a url like you want is called a GET variable. Look it up.
    Signature
    "You shouldn't come here and set yourself up as the resident wizard of oz."
    {{ DiscussionBoard.errors[7915781].message }}
    • Profile picture of the author jdem02
      this is on wordpress it will work?
      Signature


      {{ DiscussionBoard.errors[7915834].message }}
  • Profile picture of the author Andrew H
    The basics behind doing it are still the same. Except because you are using wordpress it makes it more complicated (ie: where you can put the code). I would imagine there is already a plugin to do what you want.
    Signature
    "You shouldn't come here and set yourself up as the resident wizard of oz."
    {{ DiscussionBoard.errors[7915875].message }}
    • Profile picture of the author jdem02
      <form method="post" action="http://website.com/subscribe.php"> <input type="hidden" name="CampaignCode" value="a53779680753" /> <input type="hidden" name="FormId" value="893879" /> <input type="hidden" name="PassFormData" value="1" /> <input type="hidden" name="TrackerName" value="ref" /> <input type="hidden" name="AffiliateName" value="incomedream" /> <table align="center"> <tr> <td>Email:</td><td><input type="text" name="Email" /></td> </tr> <tr> <td align="center" colspan="2"> <input type="submit" value="Submit" /></td> </tr> </table> <img src="http://www.website;c0m.com/show_form.php?id=893879" /> </form>

      Here is the form how would i do this? Sorry to bug you
      i need to campaign code, formid, and affiliatename passed from url to opt in box
      Signature


      {{ DiscussionBoard.errors[7915882].message }}
  • Profile picture of the author jdem02
    Ok i kind of got it.. I placed
    [code]add_filter('query_vars', 'parameter_queryvars' );
    function parameter_queryvars( $qvars )
    {
    $qvars[] = 'refid';
    return $qvars;
    }

    function echorefid()
    {
    global $wp_query;
    if (isset($wp_query->query_vars['refid']))
    {
    print $wp_query->query_vars['refid'];
    }
    }[code]
    In tthe functions.php but i want to pass 3 variables how can i do that?
    Signature


    {{ DiscussionBoard.errors[7916187].message }}
  • Profile picture of the author Andrew H
    So it would be something like this:


    if (isset($wp_query->query_vars['refid'])) {
    //set the refid to a variable for easier use later
    $refid = $wp_query->query_vars['refid'];
    }


    and then in your form you need to echo out this variable into the value attribute

    <input type="hidden" name="TrackerName" value="<?php echo $refid; ?>" />

    Tip: change the input type from "hidden" to "text" so you can view if the variables are being passed.
    Signature
    "You shouldn't come here and set yourself up as the resident wizard of oz."
    {{ DiscussionBoard.errors[7916231].message }}
    • Profile picture of the author jdem02
      Im dumb with code lol sorry.. Ok so how will all 3 variables get passed from url to my opt in form. Wont they all say the same variable?
      I echoed it out into all 3 fields and it came up as the same thing.
      Signature


      {{ DiscussionBoard.errors[7916280].message }}
      • Profile picture of the author jdem02
        Ahhh I got it! One last question now is I dont want all 3 variables saying refid.. How can I make one say ref,cc,fid?
        Signature


        {{ DiscussionBoard.errors[7916293].message }}
  • Profile picture of the author Andrew H
    So in your URL you have three GET variable

    yourwebite.com/?ref=ixxx&fid=xxxx0&cc=exxx

    1. ref (which equals ixxx)
    2. fid (which equals xxxx)
    3. cc (which equals exxx)

    So in your code right now you are only grabbing the ref variable and echoing that variable. Do the same thing for the other two variables fid & cc.

    In your code you are also using 'refid' which isn't even a variable in the url you supplied.
    Signature
    "You shouldn't come here and set yourself up as the resident wizard of oz."
    {{ DiscussionBoard.errors[7916305].message }}
  • Profile picture of the author jdem02
    Ok so how do I do tha tthen? do i just put <?php echofid();?>for the fid value or do i have to change something in the functions?
    Signature


    {{ DiscussionBoard.errors[7916313].message }}
  • Profile picture of the author Andrew H
    if (isset($wp_query->query_vars['ref'])) {
    //set the ref to a variable for easier use later
    $ref= $wp_query->query_vars['ref'];
    }
    if (isset($wp_query->query_vars['fid'])) {
    //set the fid to a variable for easier use later
    $fid= $wp_query->query_vars['fid'];
    }
    if (isset($wp_query->query_vars['cc'])) {
    //set the refid to a variable for easier use later
    $cc = $wp_query->query_vars['cc'];
    }

    With the above I am assuming $wp_query->query_vars['variable'] is grabbing the get variable because that is the code you supplied.

    So then we can take all those values from above and echo them into the right form inputs

    value="<?php echo $ref;?>"
    value="<?php echo $fid;?>"
    value="<?php echo $cc;?>"

    If you still don't understand, do some research because that's as simple as it's gonna get.
    Signature
    "You shouldn't come here and set yourself up as the resident wizard of oz."
    {{ DiscussionBoard.errors[7916335].message }}
  • Profile picture of the author jdem02
    I got what you mean. I added that first part into functions and added the value. Heres the problem what is this code supposed to look like?
    add_filter('query_vars', 'parameter_queryvars' );
    function parameter_queryvars( $qvars )
    {
    $qvars[] = 'refid';
    return $qvars;
    }

    function echorefid()
    {
    global $wp_query;
    if (isset($wp_query->query_vars['refid']))
    {
    print $wp_query->query_vars['refid'];
    }
    }


    Its not calling the variables and i think its somethng to do with this code?
    Signature


    {{ DiscussionBoard.errors[7916348].message }}
  • Profile picture of the author jdem02
    I got it man thanks soooo much for your help!
    had to add the qvars for each one
    Signature


    {{ DiscussionBoard.errors[7916577].message }}

Trending Topics