Showing posts with label Blog Tips. Show all posts
Showing posts with label Blog Tips. Show all posts

Sunday, December 6, 2009

Google Analytics new asynchronous tracking code

Google Analytics has now provides new asynchronous tracking code. The main feature of the asynchronous code is that it could load ga.js while the page is being rendered.

There are two ways to use this code.

  1. Place the code below before the  </head> tag.
     <script type="text/javascript">  
     var _gaq = _gaq || [];  
     _gaq.push(['_setAccount', 'UA-XXXXX-X']);  
     (function() {  
       var ga = document.createElement('script');  
       ga.src = ('https:' == document.location.protocol  
         ? 'https://ssl' : 'http://www')  
         + '';  
       ga.setAttribute('async', 'true');  

  2. Split the code. Half of the code will be put before the </head> tag. Another half will be put at the end of the page, before the </body> tag.
    The first half (before </head> the tag).
     <script type="text/javascript">  
     var _gaq = _gaq || [];  
     _gaq.push(['_setAccount', 'UA-XXXXX-X']);  
    The second half (before </body> the tag).
     <script type="text/javascript">  
     (function() {  
       var ga = document.createElement('script');  
       ga.src = ('https:' == document.location.protocol  
         ? 'https://ssl' : 'http://www')  
         + '';  
       ga.setAttribute('async', 'true');  


  1. Remove any existing Google Analytics code before using this asynchronous code.

  2. Disable any Google Analytics plugin (if you use one) for WordPress.

  3. Replace UA-XXXXX-X with your web property ID.

Thursday, November 19, 2009

How to use CSS to style code snippets

It is easy to use CSS to style code snippets, as shown in Figure 1.

[caption id="attachment_2836" align="alignnone" caption="Figure 1: Sample output of CSS style for code snippets"]Figure 1: Sample output of CSS style for code snippets[/caption]

Step 1: Append this code inside a style sheet.

pre{ font-size:12px; background:#fff; border:1px solid #000; line-height:20px; width:600px; overflow:auto; overflow-y:hidden; margin:0; padding:0; } pre code{ font-family:Monaco,Courier; display:block; margin:0 0 0 40px; padding:18px 0; } 

Step 2: Put the code snippets inside <pre> and <code> tags.

<pre><code>def f(): txt = "Some sample code" return txt </code></pre>

Friday, June 19, 2009

Free desktop client for Google Analytics

Polaris is a free desktop client for Google Analytics for single website.

To monitor multiple websites, Polaris costs $15 per year.

Here are some snapshots of Polaris.

The Dashboard.

Shows which keywords are used mostly on searches.

Referring Sites.

Top Content.

Traffic Sources.

Map Overlay.

Visits Overview.

How to get Polaris

Click here to download Polaris.

Click here to download Adobe Air (required).

Saturday, May 30, 2009

How to set the font size using CSS

First reset 1em to 10px for the whole page.
body {
font-size: 62.5%; /* Resets 1em to 10px */

Finally, set the font size for a section, such as the content.
#content {
font-size: 1.6em;
line-height: 1.6em;

1.6em is equal to 16px.

The line-height is the distance between lines.

Thursday, April 30, 2009

Monday, October 20, 2008

Blog Editor Tools

Here is the list of blog editor tools.

  1. Windows Live Writer

  2. w.blogger

  3. Scribefire

  4. Qumana

  5. BlogJet

  6. BlogDesk

  7. Zoundry Raven

  8. Post2Blog

  9. ecto

  10. MarsEdit

If you don’t see an editor on the list that you can’t live without, please take a second and leave a comment about it.

Monday, August 18, 2008

9 ways to hide affiliate links

These codes are useful for hiding the affiliate links. However, please read the affiliate program terms of service, so that you won’t go against it.

For all except the last way (.htaccess redirect), create the respective file for each affiliate link with the code for the chosen redirect style. Replace ‘http://your-affiliate-link-goes-here’ with the URL of the affiliate link.

For example, if you choose to use the PHP redirect, first create a PHP file. Copy and paste the PHP redirect code into that file. Replace ‘http://your-affiliate-link-goes-here’ with the affiliate link URL.

Every time you want to link to the affiliate link, just link to that file.

You have to create new file for each affiliate link.

HTML redirect

<title>HTML Redirect</title>
<meta http-equiv="refresh" content="0;
Please wait. Redirecting...

PHP redirect

<?php header("Location: http://your-affiliate-link-goes-here"); ?>

ASP redirect

<%@ Language=VBScript %>
<% Response.AddHeader "Location","http://your-affiliate-link-goes-here" %>

ASP.NET redirect

<script runat="server">
private void Page_Load(object sender, System.EventArgs e)

Coldfusion redirect

<.cfheader name="Location" value="http://your-affiliate-link-goes-here">

JSP redirect

<% response.setHeader( "Location", "http://your-affiliate-link-goes-here" );
response.setHeader( "Connection", "close" ); %>

cgi Perl redirect

$q = new CGI; print $q->redirect("http://your-affiliate-link-goes-here");

Ruby on Rails redirect

def old_action redirect_to "http://your-affiliate-link-goes-here" end

Apache .htaccess on Linux

Add this code to the end of .htaccess file. Replace ‘http://your-affiliate-link-goes-here’ with the affiliate link URL. To have more than one affiliate link, just add another RewriteRule.
RewriteEngine on RewriteRule ^affliate.php$
http://your-affiliate-link-goes-here [R]

Monday, July 14, 2008

Nuffnang down time

This morning, Nuffnang server seems to be down.

[caption id="attachment_260" align="alignnone" caption="Top banner"]Top banner[/caption]

[function.mysql-connect] =

[caption id="attachment_261" align="alignnone" caption="Between post"]Between post[/caption]

Wednesday, June 25, 2008

Nuffnang vs Advertlets at random

This tutorial will show on how to make Nuffnang and Advertlets ads to display at random (not at the same time on each page).

First you need to put this code in the header.php file.
global $x;
$x = rand(1,2);
This code will generate a random number of 1 and 2, and then substitutes it to the global variable x.

Next, insert the nuffnang and advertlets inside the code below.
if ($GLOBALS['x'] == 1) { ?>
<!--nuffnang--> <?php } else {?>
<!--advertlets--> <?php } ?>
Now, just copy the code and paste it into the template, as many as desired.

The code will show one or more nuffnang or advertlets ads at random with a chances of 50%.

Monday, June 23, 2008

Who digg your article

Ever wonder who digg your submitted articles to

You can easily check it within seconds with this site:

What you need is your username. No password is needed.

Saturday, June 14, 2008

Create a Rotating Ads

If you run more than one ads, but lack of space to put the ads, you can actually rotate the ads.

The code below will create a random number from 1 to 10. Since I want both ads to be shown with a probability of 50%, I put the condition if (x > 5). However, you can change this number.

<?php $x = rand(1,10); ?>
<?php if ($x > 5) { ?>

<!--your first ad code-->

<?php } else {?>

<!--your second ad code-->

<?php } ?>
You can read more about PHP rand() function here.

Sunday, May 25, 2008

Two Web Analytics Software for Desktop

Most of use might have used Google Analytics for whatever reasons. Google Analytics could help us to learn about where our visitors come from and how they interact with our site. This service is brought online by Google for free.

Ever wonder if you could view your Google Analytics results at your desktop? Yes, it can be done by using a software developed by Nicolas, called Google Analytics AIR. It was built under the Adobe AIR platform. However, you still need to have the Google Analytics account in order to use this software.

The second desktop Web analytics software is by Woopra. The platform used is Java, and is developed by Woopra. Although Woopra is currently in it's beta stage, don't under estimated it. It can even gives you live report, i.e. how many users are currently visiting your site. In order to use this software, you need to have an account with Woopra.

In my humble opinion, Woopra is better than Google Analytics, especially the reporting style. What about you?

Wednesday, April 16, 2008

How to embed source code in a blog


To embed source code inside blogger blog, like in the picture above, I use a css box like below:

.code {
font-family: ‘Courier New’, Courier, monospace;
white-space: pre;
line-height: 1.4em;
margin: 1em 0;
border: 1px dashed #aaa8a8;
padding: 0.5em 0 0.3em 0.5em;
font-size: 100%;
color: #000;
overflow: auto;
max-width: 100%;
/*max-height: 400px;*/

To use it just call the class named ’code’ using div.
<div class="code"> The source code goes here! </div>

The tab will be preserved. In order to limit the height of the box, remove the comment (”/*” and “*/”) from the last line, and set the desired height.
/* max-height: 400px; */

For some reason, in IE, the text will be wrapped instead of displaying the scroll bar. However, it works just fine inside Firefox and Opera. If you have suggestion on how to solve this problem, don’t hesitate to leave a comment.

Check your blog load time

This tool could be used to determine a blog load time.

Enter your domain name in the text box, for example

Tuesday, April 1, 2008

Ping your blog to technorati

To automatically ping Technorati, whenever you submit new post, enter the following URI in your blog configuration:

For example, if you are using WordPress, go to Settings > Writing, scroll down to Update Services section, and enter the URI.