phpAdsNew   Home  

 

 

 

  5.1 Using HTML banners  

 

HTML banners can be very powerful, but also very complicated. If you have used HTML banners before, you probably have noticed it doesn't always do what you want. Logging AdClicks can be pain, but most problems can be solved automatically, but sometimes the HTML is just too complicated to let phpAdsNew handle this.

 
   
  5.1.1 Automatic logging of AdClicks  

 


Logging of AdClicks can be very complicated. Most HTML banners included hard-coded links to the target destination. This will cause the browser to visit the target destination directly, without using phpAdsNew's AdClick logging mechanism.

However if you are using simple HTML banners phpAdsNew can automatically alter the HTML you entered in such a way it will replace the hardcoded target destination with the AdClick logging mechanism. This behavoir is turned on by default. If you want to turn it off, you should uncheck the Change HTML in order to log AdClicks checkbox.


Text

The most simple HTML banner you could use is just plain text, with or without HTML layout tags.
If you enter the target destination in the field 'Linked to URL' phpAdsNew will automatically create a link to the target destination and will log the AdClicks. If you leave the 'Linked to URL' field empty phpAdsNew will not alter the HTML in any way.

<h2>Simple text banner</h2>


Links

Links are probably the most used type of HTML banners. Hard-coded URLs normally will prevent phpAdsNew from logging AdClicks, but if 'Change HTML in order to log AdClicks' is enabled phpAdsNew will try to replaced these hard-coded URLs with the correct code to log AdClicks. If the HTML banners contains multiple links to multiple targets it will replace all links while keeping their target URLs intact.

<a href='http://www.foobar.com'>Simple link</a>


Forms
If your HTML banner contains a form phpAdsNew can automatically alter the HTML in order to log AdClicks. The action parameter will be replaced with the AdClick loggin mechanism and the original parameter will be added as a hidden field. All fields which are not needed for the functioning of phpAdsNew will be passed on to the URL specified in the original action parameter. phpAdsNew can handle both GET and POST methods, but will always use the GET method to pass the contents fields to the original URL. The following fieldnames should not be used: bannerID, dest, ismap and cb.

<form action='http://www.foobar.com/form.cgi'>
  <input name='field1' type='text'>
  <input name='field2' type='text'>
  <input type='submit'>
</form>

 

 
   
  5.1.2 Inserting variables  

 


As you can read in the section above, phpAdsNew can automatically change HTML banner in a way clicks are automatically logged. In certain cases the HTML banner is just too complicated to let phpAdsNew do this automatically. In that case you need to do this manually. In order to make this as easy a possible a number of variables can be used to assist you. Each variable will be replaced with the appropriate code during the banner invocation.


{timestamp}

You can use this variable to include a timestamp. This variable is replaced with the number of seconds since the UNIX-epoch.


{random}

In certain cases, you may want to add a random string to your HTML banner. The string {random} will be replaced with a random number of eight digits. If you need a random number with a different length, you could optionally specify the length: {random:x} (x can be any number from 1 to 9).

If you use multiple random variables inside your HTML banner they will all be replaced with the same random string. There is an exception however: if you specify random variable of a different lenght than the previous random variable a new random number will be generated.


{bannerid}

If you want to include the id of the banner, which is displayed in the HTML, you can use this variable. Every occurrence of the string '{bannerid}' will be replaced by the correct ID.


{targeturl}

The {targeturl} variable is used for manually adding the AdClick log routines to your HTML banner. There are two different ways to use this variable: without an URL and with a URL.

<a href='{targeturl}'>Click me</a>

The variable will be replaced with the correct code to log the click and redirect the browser to the URL you specified in the 'Linked to URL' field. If you specify this variable multiple times it will redirect to the url specified in the 'Linked to URL' field every time.

<a href='{targeturl:http://www.foobar.com}'>Click me</a>

The variable will be replaced with the correct code to log the click and redirect the browser to the url you specified inside the variable, in this case www.foobar.com. You can specify this variable multiple times inside the same HTML code, even if your HTML code includes multiple links to different URLs. Every link will redirect to the URL specified and will log the click if the user decides to click on one of those links, for example:

<a href='{targeturl:http://www.foobar.com/ }'>Main page</a>
<a href='{targeturl:http://www.foobar.com/producta/}'>Product A</a>
<a href='{targeturl:http://www.foobar.com/productb/}'>Product B</a>

 

 
   
  5.1.3 Embedding PHP code  

 


In certain cases you may want to embed PHP code inside an HTML banner.
You can do this in the same way as you would normally embed PHP code inside an HTML document. PHP code starts with <?php and ends with ?>. All code between these two tags will be executed just as it would if it were embedded inside a normal HTML document.

There are some exceptions: It is not possible to define function or classes and include or require other files. The print(), echo and printf() functions will still work and can be used to print strings to the HTML banner.

<a href='http://www.mybanner.com/click'>
<?php
  echo "The current time is: ";
  echo date ("H:i:s");
?>
</a>