How do counter services that enable their users to insert a section of HTML on their webpage to display a counter work.

I am wanting to build one in PHP but am having trouble cracking the method.

If anyone has an insight.

NB: I am guessing you use GD libraries, not to sure though