1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

HELP >> Passing variable data into a link on my page (to track sales)

Discussion in 'PHP & Perl' started by cdn_craigs, Dec 19, 2015.

  1. cdn_craigs

    cdn_craigs Jr. VIP Jr. VIP

    Joined:
    Jul 16, 2011
    Messages:
    1,368
    Likes Received:
    386
    Occupation:
    PAY PER CALL GURU at your service...
    Location:
    Canada
    Home Page:
    hi guys

    i want to pass info that is in my link to a button code on my page (so i can track source of my sales)

    EXAMPLE: my url is www.example.com?src=facebook (this is from a facebook ad)

    so on the page, my BUY NOW link is: www.example.com/purchase . how do i dynamically insert >> "?src=facebook" at the end of my url. (so i know this sale came from facebook) my sales tracking system allows passing variable content to it.

    HOW DO I DO THIS? What code do i use on my buy now button to pull the info from the passed info?

    I am on wordpress, and have ALLOW PHP ON PAGE plugin (so php code works on the page)

    thanks guys...
     
  2. cdn_craigs

    cdn_craigs Jr. VIP Jr. VIP

    Joined:
    Jul 16, 2011
    Messages:
    1,368
    Likes Received:
    386
    Occupation:
    PAY PER CALL GURU at your service...
    Location:
    Canada
    Home Page:
    nobody know... :(
     
  3. DSNYC

    DSNYC Jr. VIP Jr. VIP Premium Member

    Joined:
    Dec 23, 2014
    Messages:
    196
    Likes Received:
    41
    Location:
    New York, NY
    Code:
     [COLOR=#000000] [COLOR=#0000BB]<?php
    [/COLOR][COLOR=#007700]$source =[/COLOR][COLOR=#0000BB]htmlspecialchars[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]$_GET[/COLOR][COLOR=#007700][[/COLOR][COLOR=#DD0000]"src"[/COLOR][COLOR=#007700]]);
    [/COLOR][/COLOR][COLOR=#007700]echo [/COLOR][COLOR=#DD0000]'http://example.com/purchase?src=' [/COLOR][COLOR=#007700]. [/COLOR][COLOR=#007700][COLOR=#0000BB]$source[/COLOR] . [/COLOR][COLOR=#DD0000]''[/COLOR];
    [COLOR=#000000][COLOR=#0000BB]?>[/COLOR] [/COLOR] 
    
         
    
     
    • Thanks Thanks x 1
  4. cdn_craigs

    cdn_craigs Jr. VIP Jr. VIP

    Joined:
    Jul 16, 2011
    Messages:
    1,368
    Likes Received:
    386
    Occupation:
    PAY PER CALL GURU at your service...
    Location:
    Canada
    Home Page:
    so i put this in the head..

     
  5. cdn_craigs

    cdn_craigs Jr. VIP Jr. VIP

    Joined:
    Jul 16, 2011
    Messages:
    1,368
    Likes Received:
    386
    Occupation:
    PAY PER CALL GURU at your service...
    Location:
    Canada
    Home Page:
    what do i put in my button link? do i put this > www.example.com/purchase?src=

    Sorry just need to understand how the variable, get added to the url link on the button.
     
  6. Serhi

    Serhi Newbie

    Joined:
    Dec 18, 2015
    Messages:
    20
    Likes Received:
    2
    Occupation:
    Developer of http://bulkaddurl.com
    Home Page:
    Give the code of your button and we will be able to give you what you need.

    For example, if now your BUY button is
    Code:
    <a href='/purchase'>BUY<a>
    You should change it to
    PHP:
    $src htmlspecialchars($_GET['src']);
    print 
    "<a href='/purchase?src=$src'>BUY<a>";
     
    • Thanks Thanks x 1
  7. cdn_craigs

    cdn_craigs Jr. VIP Jr. VIP

    Joined:
    Jul 16, 2011
    Messages:
    1,368
    Likes Received:
    386
    Occupation:
    PAY PER CALL GURU at your service...
    Location:
    Canada
    Home Page:
    Thank you sir - let me try it and i will report back

     
  8. cdn_craigs

    cdn_craigs Jr. VIP Jr. VIP

    Joined:
    Jul 16, 2011
    Messages:
    1,368
    Likes Received:
    386
    Occupation:
    PAY PER CALL GURU at your service...
    Location:
    Canada
    Home Page:
    ok, not sure how to add the code here:

    Code:
    
    <form accept-charset="UTF-8" action="[B][COLOR=#ff0000]https://www.e-junkie.com/ecom/gb.php?c=cart&cl=XXXXXX&ejc=2[/COLOR][/B]" method="POST" target="ej_ejc"><select name="i">
    <option value="">Select Current Option</option>
    <option value="1449525">Oil Change</option>
    <option value="1449526">air filter</option>
    </select>
    
    
    <input class="ec_ejc_thkbx" alt="Buy Now" src="http://mydomain.com/wp-content/uploads/2015/02/buy-now-button5.png" type="image"><img class="alignnone wp-image-615 " src="http://mydomain.com/wp-content/uploads/2015/07/paypal-credit-cards-1.png" alt="Accepted payments types: Paypal, All Major Credit cards, Debit card." width="191" height="73">
     
  9. Serhi

    Serhi Newbie

    Joined:
    Dec 18, 2015
    Messages:
    20
    Likes Received:
    2
    Occupation:
    Developer of http://bulkaddurl.com
    Home Page:
    Try this code:

    Code:
    
    <php
    $src = htmlspecialchars($_GET['src']);
    ?>
    <form accept-charset="UTF-8" action="[B][COLOR=#ff0000]***/ecom/gb.php?c=cart&cl=XXXXXX&ejc=2[/COLOR][/B][B][COLOR=#ff0000]&src=<?=$src ?>[/COLOR][/B]" method="POST" target="ej_ejc">
    <input type=hidden name="src" value="<?=$src ?>">
    <select name="i">
    <option value="">Select Current Option</option>
    <option value="1449525">Oil Change</option>
    <option value="1449526">air filter</option>
    </select>
    
    
    <input class="ec_ejc_thkbx" alt="Buy Now" src="***/wp-content/uploads/2015/02/buy-now-button5.png" type="image"><img class="alignnone wp-image-615 " src="***/wp-content/uploads/2015/07/paypal-credit-cards-1.png" alt="Accepted payments types: Paypal, All Major Credit cards, Debit card." width="191" height="73">
    And aftet that your script ***/ecom/gb.php will get the $src value.

    But change *** to your domain (I can't post links now so I get error "You are NOT allowed to post URLs")
     
    • Thanks Thanks x 1
  10. cdn_craigs

    cdn_craigs Jr. VIP Jr. VIP

    Joined:
    Jul 16, 2011
    Messages:
    1,368
    Likes Received:
    386
    Occupation:
    PAY PER CALL GURU at your service...
    Location:
    Canada
    Home Page:
    hi Seri,

    I tried this, and now my DROP DOWN to select those option shown is not a dropdown, just a list of text on the page? ideas of why that happened? looks like it broke the code for the dropdown menu.

     
  11. Diplomat

    Diplomat Jr. VIP Jr. VIP

    Joined:
    Oct 25, 2011
    Messages:
    948
    Likes Received:
    440
    Home Page:
    You know, it would be much easier to use Javascript to append that code into your links.. that way you wont have to write PHP code and stuff like that.
     
  12. cdn_craigs

    cdn_craigs Jr. VIP Jr. VIP

    Joined:
    Jul 16, 2011
    Messages:
    1,368
    Likes Received:
    386
    Occupation:
    PAY PER CALL GURU at your service...
    Location:
    Canada
    Home Page:
    Can you reccomend anyone that could write it for me - im more a marketer than a coder to be honest.
     
  13. Diplomat

    Diplomat Jr. VIP Jr. VIP

    Joined:
    Oct 25, 2011
    Messages:
    948
    Likes Received:
    440
    Home Page:
    Hey!

    Sorry for the late reply, didn't notice that you replied..

    Maybe something like this?

    Code:
    <script type="text/javascript">
    (function()
    {
        var addOn = 'src=facebook';
        
        var links = document.getElementsByTagName('a');
        
        for(var i = 0; i < links.length; i++)
        {
            links[i].href = (links[i].href + (links[i].href.indexOf('?') > 0 ? '&' : '?')) + addOn;
        }
    })();
    </script>
    
    It will add "src=facebook" to ALL links that you have on page.
     
    • Thanks Thanks x 1
  14. cdn_craigs

    cdn_craigs Jr. VIP Jr. VIP

    Joined:
    Jul 16, 2011
    Messages:
    1,368
    Likes Received:
    386
    Occupation:
    PAY PER CALL GURU at your service...
    Location:
    Canada
    Home Page:
    Actually i had a PHP code work with me on it - its working now :)
     
  15. revproxy

    revproxy BANNED BANNED Jr. VIP Premium Member

    Joined:
    Nov 20, 2015
    Messages:
    396
    Likes Received:
    100
    Gender:
    Male
    Better solution.
    in your php header search for "src" params and insert it to your $_SESSION.
    then you can access this var from any page without adding the param