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

cdn_craigs

Elite Member
Joined
Jul 16, 2011
Messages
1,932
Reaction score
697
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...
 
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]
 
so i put this in the head..

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]
 
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>";
 
Thank you sir - let me try it and i will report back

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 rel='nofollow' href='/purchase?src=$src'>BUY<a>";
 
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">

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 rel='nofollow' href='/purchase?src=$src'>BUY<a>";
 
ok, not sure how to add the code here:

Code:
<form accept-charset="UTF-8" action="[B][COLOR=#ff0000]***/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="***/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">

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")
 
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.

Try this code:

Code:
<php
$src = htmlspecialchars($_GET['src']);
?>
<form accept-charset="UTF-8" action="[B][COLOR=#ff0000]***/ecom/gb.php>[/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")
 
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.
 
Can you reccomend anyone that could write it for me - im more a marketer than a coder to be honest.
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.
 
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.
 
Actually i had a PHP code work with me on it - its working now :)
 
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
 
Back
Top