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:

<!-- 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>
AttributeRequiredDescription
data-urlURL of the page
data-uidCustom UID, if the thread uses one different from the URL
data-guidLegacy GUID (WordPress compatibility)
👍

Using uid on your threads?

If your widget embeds set behaviour.uid (recommended — see 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:

<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


Did this page help you?