How to add a flag counter to any website (HTML code)
Free flag counter and visitor counter HTML code: copy one line into your page and see visitor flags from around the world. Works on any site you can edit.
Updated · takes about 2 minutes
If you can edit your site's HTML, you can add Live Flag Counter. The counter is a single image wrapped in a link: no JavaScript, no cookies and nothing to install.
It works on hand-written pages, static site generators such as Hugo, Jekyll, Eleventy and Astro, on Neocities, and in any CMS that lets you paste HTML.
Step by step
-
Design your counter
On our homepage, pick a layout (grid, list or badge), your colours and how many flags to show, then click Create my counter. No account is needed.
-
Copy the HTML code
On the next page, open the HTML tab and click Copy. Save your private edit key somewhere safe — you need it to change the counter later.
-
Paste it where it should appear
Open your page in your editor and paste the code where you want the flags — usually the footer or a sidebar. For a counter on every page, put it in your shared footer or layout template.
-
Publish and check
Upload or deploy the page and open it in your browser. Your visit is counted straight away; click the widget to open the full statistics.
What the code looks like
This is the HTML code. Yours contains your own counter ID instead of YOUR-ID, so always copy it from your counter's page.
<a href="https://liveflagcounter.com/stats/YOUR-ID" target="_blank" rel="noopener"> <img src="https://liveflagcounter.com/c/YOUR-ID.png" alt="Live Flag Counter" width="456" style="max-width:100%;height:auto"> </a>
Tips for any website
- The code includes the widget's width (or, for badges, its height), so it stays sharp and the page doesn't jump while loading.
- Keep the code exactly as copied. To change the design later, use the edit page — your widget updates by itself. Only if its size changes (for example more columns) will we ask you to copy the new code.
- Only want visits from your own domain counted? Add it under Advanced → Only count visits from these sites when you create the counter.
- On narrow screens the widget scales down if your CSS includes
img { max-width: 100%; height: auto; }, as most themes do.
Questions
Does a flag counter slow down my website?
No. It is one small image, loaded like any other picture. There is no script that could block or delay your page.
Do I have to add the code to every page?
Only to the pages you want counted. Most people put it in their footer template, so it appears — and counts — on every page.
Add a flag counter to any website
Create your free counter in seconds. No signup, no watermark, no cookies.
Create your counter