nxt's place

Tracking organic ranking with google analytics

by on Oct.11, 2010, under Other

If you want to track your rank in the organic search results you can do the following:
First we need to check the referrer and see if it contains the necessary bits.

1
2
3
4
var rank= /^(?:http|https)\:\/\/(?:.+\.)*google\..+(?:\?|\&)cd\=(\d+)/.exec(document.referrer || '');
if(match) {
  alert('position = ' + rank[1]);
}

The next thing we want to do is modify our analytics tracker code to include a custom variable:

1
2
3
4
5
6
7
var rank= /^(?:http|https)\:\/\/(?:.+\.)*google\..+(?:\?|\&)cd\=(\d+)/.exec(document.referrer || '');
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXX-X']);
if(rank) {
  _gaq.push(['_setCustomVar',1,'Google_Ranking',rank[1],2]);
}
_gaq.push(['_trackPageview']);

We’ve set the custom variable to slot 1, and the last number two means that we scope it to the session.

Finally you’ll want to wrap it up in a closure to prevent polluting the global scope:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
var _gaq = _gaq || [];
(function() {
  var rank= /^(?:http|https)\:\/\/(?:.+\.)*google\..+(?:\?|\&)cd\=(\d+)/.exec(document.referrer || '');
  _gaq.push(['_setAccount', 'UA-XXXXXX-X']);
  if(rank) {
    _gaq.push(['_setCustomVar',1,'Google_Ranking',rank[1],2]);
  }
  _gaq.push(['_trackPageview']);
 
  var ga = document.createElement('script'); ga.type = 'text/javascript'; 
  ga.async = true;
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  var s = document.getElementsByTagName('script')[0];
  s.parentNode.insertBefore(ga, s);
})();

You can view your new statistics using the Advanced segmentation feature of Google analytics, but keep in mind that it’s only possible to harvest data from the links that are clicked on.

Comments Off on Tracking organic ranking with google analytics :, , more...

Companies and OpenID

by on Apr.15, 2009, under Personal

What is wrong with OpenID, 

Well nothing actually, you can have multiple identities, sign in on several websites using that identity.  And if you don't trust a third party with your login credentials it is also very easy to setup your very own OpenID server.

Than what went wrong. well, lately several companies started to claim to support OpenID. For instance, your gmail, yahoo, hyves accounts (and soon windows live) are now OpenID identities. They all provide you with an identity but none of them allows you to another identity to sign on their sites. This completely defeats the purpose. If I wanted an identity, there are already tons of sites that will provide me one. It would be far more usefull if they would actually allow me to log in using an openid.

Comments Off on Companies and OpenID : more...

IPv6

by on Sep.15, 2008, under Other

I decided it was time to start experimenting with IPv6.
I started with go6.net, so I created an account and installed the software for the tunnel on my linux machine.
apt-get install tspc
add the account info to the config file and you're ready to go. It worked instantly. However it was a little slow (200kB/s and ping times up to 300ms) but that is probably related to the distance between our locations.

So next I tried Hurricaine Electric which have an endpoint at the AMS-IX so that should give me better speed, or at least better ping times. They offer no custom software but instead use protocol 41. Unfortunately it seems that my linksys BEFW11S4 router doesn't let that traffic through (not even when I place my machine in the DMZ) so I looked on.

I finally ended at SixXS which also has several tunnel endpoints in the Netherlands and offer an UDP based protocol that is capable to pass through NAT.  Their software works I get very good speeds and ping times here. The only downside I could find is that you'll have to wait for a week before you can request a /48 subnet, but this should'nt be a big problem, just be patient and besides it gives you the time to figure out how you want to configure your network.
Their service works very good and I'm glad I signed up there. 

Now all I need to do is find a router that is capable of passing protocol 41 and convert my ayiya based tunnel to one that provides less overhead.

Comments Off on IPv6 :, more...

IE8: opt-out mime sniffing

by on Jul.22, 2008, under Other

According to a recent blog entry on msdn  Microsoft has finally decided to fix a very annoying 'feature' of internet explorer. Mime-sniffing.

 It always irritated me that when I specified a content-type for a web page, Internet Explorer would just look at the content and say: "your wrong" and renders the page the way it thinks you intended.
If I give a html page text/plain as content-type I intend to let it show the source, not render it as html because if I wanted that I would have given it text/html as content-type.

At least in IE8 they allow us to disable the mime sniffing by appending ";authoritative=true" to the content-type header. This way it won't hurt other browsers and we are still able to provide the mime type ourselves.

Comments Off on IE8: opt-out mime sniffing :, , , more...

JNA: Java Native Access

by on Dec.09, 2007, under Java

If you use JNI to access native code you'll quickly find yourself writing some glue in c/c++ to access the native library. With JNA you can write nice clean code in Java without the need to glue your java code to the native library. This is all done by JNA.

All you need to do is define an interface that  (extends the Library interface and) exposes the methods in the library that you want to access:
import com.sun.jna.*;
// kernel32.dll uses the __stdcall calling convention
// Most C libraries will just extend com.sun.jna.Library
public interface Kernel32 extends StdCallLibrary {
// Method declarations, constant and structure definitions go here
}

Next you load the library using the following code:
Kernel32 kernel32Instance = (Kernel32)
    Native.loadLibrary("kernel32", Kernel32.class);

That's all there is to it, you can now access all methods you defined in the interface.
 Checkout the project page

Comments Off on JNA: Java Native Access :, , , more...

cross domain AJAX

by on Nov.24, 2006, under Java

Using AJAX (which implies the use of the XMLHttpRequest) has one big
limitation, you can only make requests to the server from where the
page was downloaded.
As an alternative you can use javascript to dynamically include other javascript files which should be generated serverside.

An example on how to call the server:

function callServer() {
 var head = document.getElementsByTagName("head").item(0);
 var myTag = document.createElement("script");
 myTag.setAttribute("type", "text/javascript");
 myTag.setAttribute("src",
  "http://example.com/application/getjs/?var1=value1");
 head.appendChild(myTag);
}

The idea is that you generate the javascript that you need by dynamically add another script tag on the page.
for an excellent example of this approach you can read this javaworld article

Comments Off on cross domain AJAX :, , more...

Fuse 0.1

by on Feb.10, 2006, under Java

Fuse 0.1 has been released

A brief overview of the features in this release:
* Multiple ResourceInjector instance support
* TypeLoader property support
* Global resource syntax
* SWT support
* Fully modular architecture (/Core, /Swing, and /SWT)
* Documentation (both javadoc and TypeLoader specific)
* A brand new build system and instructions on how to use it

Comments Off on Fuse 0.1 :, , more...

Fuse, UI Oriented Resource Injection

by on Feb.04, 2006, under Java

With Fuse you can easily inject data in your application at runtime by specifying them in a properties file,
for example using an background image
you used to do something like this:
class CustomComponent extends JComponent {
 private Image background;
 CustomComponent() {
  try {
   background = ImageIO.read(getClass()
    .getResource("/resources/background.png"));
  } catch (IOException e) { }
 }
}

With fuse the code would look like this
class CustomComponent extends JComponent {
 @InjectedResource
 private Image background;
 CustomComponent() {
  ResourceInjector.get().inject(this);
 }
}

Ofcourse you must load a properties file before calling inject using:
ResourceInjector rInjector=
 ResourceInjector.get().load("/resources/fuse.theme");

For more information about Fuse see this entry in the Romain Guy's blog. or take a look at the project page
 

Comments Off on Fuse, UI Oriented Resource Injection :, , more...

new car

by on Jan.14, 2006, under Personal

I finally bought a car.
car

Comments Off on new car : more...

Wireless

by on Dec.30, 2005, under Other

I recently bought the 3com OfficeConnect travel router to have wireless internet whenever I'm at my parents.
I'm very pleased to see that – despite some reviews I've read – the range is very good.
I chose this one because it can function as an accesspoint, router or
client. The client mode can be usefull when I'm with other people since
my laptop (acer travelmate 800LCi) only has 11b, so I can get some
higher speeds with this thing. It would have been nice though if it
could optionally be powered by usb so that I wouldn't need to carry the
adapter everywhere I go.

Comments Off on Wireless :, , , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll

A few highly recommended websites...