Jump to content

Simple PHP question


mcloan

Recommended Posts

I am trying to use dynamic insertion with adwords.  I need some help with the code.

 

My url would be something like

http://www.mysite.com/landingpage.php?q={keyword}

 

Then on my landing page I would have the below code on an affilaite link.

 

<?php
$keyword = $_GET[’q'];
if(!strcmp($keyword, “”))
{
echo ‘<a href=”http://www.myaffiliatelink.com?sid=Default”>Anchor</a>’;
} else {
echo ‘<a href=”http://www.myaffiliatelink.com?sid=’ . $keyword . ‘>Anchor</a>’;
}
?>

 

However for the sid code where it picks up a $keyword I would also like to include a reference for the landing page.  For instance maybe the sid in CJ would read lp1 - $keyword.  This would allow me to split test different landing pages.  I do not know how to insert the lp1 in the above code

echo ‘<a href=”www.myaffiliatelink.com?sid=’ . $keyword . ‘>Anchor</a>’;

.

 

Is it possible?

 

If so can some help me with this?

 

Thank you.

Link to comment
Share on other sites

do you mean somewthing like:

 

echo ‘<a href=”www.myaffiliatelink.com?sid=’ . $keyword . ‘&ref='.$reference.'>Anchor</a>’;

 

hope this helps,

 

I am not sure the ref would pick up for tracking in my Commissio Junction account beasue it only picks up sid from the affiliate link.  So what I had hoped to do in make sid something like this lp1 online dating for the first landing page or lp2 online dating for the second landing page.  So essentially the new sid code would combine the lp1 with the keyword passed in the url.

 

Excuse my lack of understanding but is that what the above code does?

 

Thank you.

Link to comment
Share on other sites

the above code in question actually generates 2 $_GET variables, one $_GET['sid'] and the other $_GET['ref'].

---

 

to combine your keyword and ref into the 'sid', you could use:

 

echo ‘<a href=”www.myaffiliatelink.com?sid='.$reference.'-’ . $keyword . ‘>Anchor</a>’;

the above would produce an sid as:

 

$reference = "lp1"; $keyword = "search";

www.myaffiliatelink.com?sid=lp1-search

 

 

hope this helps,

Link to comment
Share on other sites

the above code in question actually generates 2 $_GET variables, one $_GET['sid'] and the other $_GET['ref'].

---

 

to combine your keyword and ref into the 'sid', you could use:

 

echo ‘<a href=”www.myaffiliatelink.com?sid='.$reference.'-’ . $keyword . ‘>Anchor</a>’;

the above would produce an sid as:

 

$reference = "lp1"; $keyword = "search";

www.myaffiliatelink.com?sid=lp1-search

 

 

hope this helps,

 

Perfect, that will work great.  I have one more question.  I am thinking some of my affilate links I want to redirect them though a php redirect. 

 

So I figure I can set a cookie and then in the redirect file it will read somthing like

 


<?php
header( 'Location: http://www.myaffilatelink.com?sid=<?=$_REQUEST['id']?>' ) ;
?>

 

Cookie

 

<?php

if ($_REQUEST['sid'])
{
setcookie("requestid",$_REQUEST['sid'],time()+(86400*365),"/");
}
?>

 

I have two question.  The above cookie code is setting a cookie name index in my cookies and it is 528kb.  So I do not think the code is working. 

 

Can someone suggest what I need to do to make this code work correctly?

 

Secondly, if in the link h**p://www.myaffilatelink.com?sid=<?=$_REQUEST['id']?>'  if I want to add the $reference="lp1" so that the final output will be  h**p://www.myaffiliatelink.com?sid=lp1-keyword how do I do this?

 

Your help is much appreciated.  I have been trying so many different ways and can not get any of them to work.  I am going nuts... LOL.

 

Thank you.

 

 

 

 

Link to comment
Share on other sites

ok first off the $_REQUEST array stores GET and POST data, eg query strings and submitted form data.

 

i am wondering where you would get $_REQUEST['id'] from? can you ellaborate?

 

try this:

www.myaffilatelink.com?sid=<?php echo($Reference); ?>-<?php echo($_REQUEST['id']); ?>

 

this will not work:

<?php
header( 'Location: http://www.myaffilatelink.com?sid=<?=$_REQUEST['id']?>' ) ;
?>

 

do this:

 

<?php
header( 'Location: http://www.myaffilatelink.com?sid='.$_COOKIE['requestid'] ) ;
?>

 

-- also note that cookies cannot be "Accessed" within the same executing script that "Created" the cookie.

 

 

 

hope this helps,

Link to comment
Share on other sites

it seems ok...

 

try this:

 

<?php

if ($_REQUEST['sid'])
{
setcookie("requestid","test",time()+(86400*365),"/");
}
?>

 

 

then try this:

 

<?php

if ($_REQUEST['sid'])
{
setcookie("requestid",$_REQUEST['sid'],time()+31536000,"/");
}
?>

 

and if still not proper try this:

 

<?php

if ($_REQUEST['sid'])
{
setcookie("requestid","test",time()+31536000);
}
?>

 

can you upload the contents of your cookie as an attachment?

 

 

hope this helps,

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.