---
updatedAt: 2026-07-31T11:52:40.000Z
agentTools:
  projectIndex: https://developers.graphcomment.com/llms.txt
---

# Comment count

Show "42 comments" next to your article links — one class, one script, no full widget.

Show the number of comments attached to a page — "12 comments" in an article list, on your homepage, in a related-posts block — without loading the full widget.

## Step 1 — Mark the elements

Add a `gc-counter` element for each URL you want to count:

```html
<!-- One element per URL to count -->
<div class="gc-counter" data-url="https://my.site/article-12345.html"></div>
<div class="gc-counter" data-url="https://my.site/article-67890.html"
                        data-uid="custom-uid-optional"></div>
```

| Attribute   | Required | Description                                               |
| ----------- | -------- | --------------------------------------------------------- |
| `data-url`  | ✅        | URL of the page                                           |
| `data-uid`  | —        | Custom UID, if the thread uses one different from the URL |
| `data-guid` | —        | Legacy GUID (WordPress compatibility)                     |

> 👍 Using `uid` on your threads?
> If your widget embeds set `behaviour.uid` (recommended — see [Getting Started](./getting-started)), pass the same value in `data-uid` so the counter resolves the same thread.

> ⚠️ Use the exact same URL as your embed
> `www.your-site.com/article` and `your-site.com/article` resolve to **different threads**. If the `data-url` doesn't match the URL (or `uid`) your widget embed uses, the counter shows 0 — or another thread's count. Use the same canonical URL everywhere.

## Step 2 — Load the counter script

Add this once per page, replacing `<shortname>` with your site's shortname:

```html
<script type="text/javascript">
  function __semio__onload__counter() {
    __semio__helpers_counter("<shortname>");
  }

  (function() {
    var gc = document.createElement('script');
    gc.type = 'text/javascript'; gc.async = true; gc.defer = true;
    gc.onload = __semio__onload__counter;
    gc.src = 'https://integration.graphcomment.com/helpers_counter.js?' + Date.now();
    (document.head || document.body).appendChild(gc);
  })();
</script>
```

The script walks every `.gc-counter` element on the page and replaces its content with the corresponding comment count — plain text you can style freely with your own CSS (inline count, badge, etc.).

> 📘 Need the count server-side?
> A public API endpoint returns the comment count as raw data — see `GET /api/pub/numberOfComments` in the API Reference.

## Next steps

* **[Getting Started](./getting-started)** — embed the full widget on your article pages.
* **[Widget configuration](./widget-configuration)** — thread identity (`uid`) and every widget option.