A lightweight, standalone GetSimpleCMS-CE plugin for tracking clicks on any link or button - no login required.
- Copy both
gs_Clicks.phpand thegs_Clicks/folder into your GetSimpleCMSplugins/directory, as siblings:plugins/ ├── gs_Clicks.php └── gs_Clicks/ - Open Settings → Plugins in the admin panel and activate GS Click Counter.
- Set a real random value for
GSCC_SALTings_Clicks.phpbefore going live (it's used to anonymize IP addresses in the database - don't leave the default). - That's it - the SQLite database is created automatically at
data/other/gs_Clicks.dbon first use.
{gs-click id="ebook-pdf" url="/files/ebook.pdf" label="Download PDF"}
Add show_count="1" to display the current total next to the link:
{gs-click id="ebook-pdf" url="/files/ebook.pdf" label="Download PDF" show_count="1"}
Customize the count text with count_format (%d is replaced with the number):
{gs-click id="ebook-pdf" url="/files/ebook.pdf" label="Download PDF" show_count="1" count_format="Downloads: %d"}
<?php gs_click_link('ebook-pdf', '/files/ebook.pdf', 'Download PDF'); ?> <?php gs_click_link('ebook-pdf', '/files/ebook.pdf', 'Download PDF', ['show_count' => true, 'count_format' => 'Downloads: %d']); ?>
You don't need the shortcode or template tag at all - add data-gsc-id
to any existing <a> or <button> already in your theme or page HTML,
and it's tracked automatically:
<a href="/files/ebook.pdf" data-gsc-id="ebook-pdf">Download PDF</a>
This is how you track links you already have full control over the markup for - buttons with custom classes, existing download links, anything.
Shows a ranked list of the most-clicked links, with working hyperlinks -
as long as each one was rendered at least once through the shortcode or
template tag (that's what lets the plugin remember its URL and label).
IDs tracked only via a bare data-gsc-id attribute show up by ID only,
since the plugin never saw their URL.
{gs-click-top limit="5"}
<?php gs_click_top_list(5); ?>
Same data-gsc-id attribute, just added inside JS-built markup. After
inserting new elements into the page, call GSClicks.init() to wire up
anything not already bound:
const cardHTML = `<a href="${url}" class="btn btn-primary" data-gsc-id="${id.toLowerCase()}">Download</a>`; // ...insert cardHTML into the page... GSClicks.init();
init() is safe to call repeatedly - already-bound elements are
skipped. Use GSClicks.getCounts(ids) if you want to display live
counts in your own custom markup instead of show_count:
GSClicks.getCounts(['ebook-pdf', 'other-file']).then(function (counts) { console.log(counts['ebook-pdf']); // e.g. 42 });
Or GSClicks.getTop(limit) for a ranked popular-downloads list instead
of the {gs-click-top} shortcode:
GSClicks.getTop(5).then(function (top) { // top is [{ id, count, url, label }, ...] sorted by count descending });
For a page of item cards (galleries, plugin listings, etc.) built in JS, add a placeholder next to each item's title or button, then fill in the real counts in one batch request once all cards exist:
const cardHTML = ` <div class="card"> <h5>${name}</h5> <a href="${url}" class="btn btn-primary" data-gsc-id="${id}">Download</a> <span class="download-count" data-gsc-count-for="${id}">Downloads: ...</span> </div>`; // ...insert all cards into the page, then: GSClicks.init(); GSClicks.getCounts(items.map(i => i.id)).then(function (counts) { document.querySelectorAll('[data-gsc-count-for]').forEach(function (el) { const id = el.dataset.gscCountFor; el.textContent = 'Downloads: ' + (counts[id] || 0); }); });
getCounts() takes any number of IDs in a single request, so this
works the same whether the page has 5 cards or 500.
| Attribute | Values | Default |
|---|---|---|
id |
any unique string | required |
url |
any URL | required |
label |
any text | same as id |
show_count |
0, 1 | 0 |
count_format |
text with %d, e.g. "Downloads: %d" |
(%d) |
target |
e.g. _blank |
- |
No login is required to track a click, so anonymous dedup uses the same approach as GS Ratings: a salted hash of the visitor's IP address plus a random token stored client-side. Unlike a rating, there's no "value" to update - a click either counts or doesn't. The anti-spam window (Settings tab, in minutes) controls how long a repeat click from the same visitor on the same link is ignored before counting again. Set it to 0 to count every single click with no deduping at all.