Display a GA4 popular-pages ranking in Hugo with Ranklet4
The old instructions used Google Analytics Views and a legacy Ranklet widget. The legacy Ranklet service ended in 2023. Its old widget tag must be replaced with a new tag from Ranklet4, a separate service for GA4. See the official migration notice.
Ranklet4 aggregates GA4 reporting data and serves a ranking as a JavaScript widget, including on static sites such as Hugo. Menus and plans can change, so follow the current official tutorial.
Before you start
- Have a GA4 property that records visits to your site.
- The Google Account used to sign in needs at least the Viewer role on that property. You do not need to use an account with administrator privileges.
- Ranklet4 will receive access to Google Analytics data. Its terms grant a broad license to use, copy, distribute, create derivative works from, display, and perform analytics data; they also allow non-identifying statistical information to be used and published. Review the terms and privacy policy, and confirm you may share the data before connecting. The terms differ from legacy Ranklet.
Create and publish a ranking
- Sign in to Ranklet4 with an account that can view the target GA4 property. Review the requested permission before granting access.
- Create a ranking and choose the GA4 property, reporting period, and number of entries. Set title or URL filters to exclude pages such as the home page when appropriate.
- Optionally configure title text replacement. Check the titles and results in the preview.
- Select a design-gallery template or customize the HTML/CSS template. New templates use Handlebars; check the template guide for field names and syntax.
- Save and publish, then copy the ranking tag generated in the dashboard. Do not reuse a legacy Ranklet tag or ID.
This is a minimal HTML template example. See the official guide for the supported fields and loop syntax.
| |
Add it to Hugo
- Create
layouts/partials/ranklet4.htmland paste the exact ranking tag generated by Ranklet4. - Add this Hugo partial call to the layout where the ranking should appear, such as
layouts/_default/single.htmlor a sidebar partial:
| |
- Preview the page locally, then confirm the widget loads over HTTPS after deployment. It depends on third-party JavaScript, so consider page speed, privacy notices, and your site’s security policy.
Updates and migration notes
Rankings follow GA4 reporting and Ranklet4’s refresh schedule; they may not change immediately after a visit. Refresh frequency, plan features, credits, and advertising policies can change, so check the current plan details. Ranklet4’s crawler reads public-page information; see the FAQ.
