Simple ghost stats/analytics

Is there any plan to add in some basic site stats? Just being able to see page view/reads, similar to what Medium offer, would be great.

You can insert any analytics suite of your choice into the head section of the Code Injection settings and have full statistics and details for every page on your site ā€“ which is much, much more detailed and reliable than any sort of basic viewcounter :slight_smile:

image

1 Like

Thanks @John. I had GA set up perviously. The issue with 3rd party analytics is handing that data over to a 3rd party, and that cross site trackers tend to be blocked by ad blockers. I understand they offer a much more detailed experience, but it would be nice to have a simple built in option just for views/reads.

I guess I could look at running something along side my DO install to do this for now.

3 Likes

The self-hosted analytics software Iā€™ve seen a lot is Matomo (previously Piwik). The only relative downside is itā€™s based on PHP - not that PHP is bad, but you have an additional dependency to maintain

2 Likes

Another self hosted analytics would be Fathom.

6 Likes

Thatā€™s an interesting point :thinking: ā€“ how are you handling that currently on other (non-ghost) properties, out of interest?

2 Likes

The team Iā€™m currently working with are looking at using ahoy (ruby), which is what Instacart uses. GitHub - ankane/ahoy: Simple, powerful, first-party analytics for Rails

It required building youā€™re own panel to view the data, but negates the whole 3rd party/cross-site issue, and also helps with page load times.

2 Likes

I use GoAccess now, as I found that GA was being stripped/blocked by decent adblockers, and I was a bit worried about privacy concerns.
GoAccess isnā€™t as pretty or as rich in analysis, but itā€™s very simple - doesnā€™t involve any javascript which might get blocked - and just analyses the access log of your web server, so doesnā€™t require any maintenance after the initial setup.

As well as the neat command line version, thereā€™s a pretty slick web GUI, which updates the figures and panels ā€˜liveā€™ (using websockets).

Just wanted to add my 2 pence on this, as nobody else had mentioned it and I think GoAccess fits the bill for a simple stats tool. :slight_smile:

6 Likes

Iā€™d recommend it too. I have been using it for a while now.

Sorry to bump an old thread, but something worth noting is that when the private mode is enabled, you donā€™t see (Google) Analytics when injected via the control panel on that specific page. Iā€™ll be looking for a workaround within the code, but itā€™d be nice to have stats for that page to learn if users are visiting the site without proceeding.

Totally unrelated, just out of curiosity: can removing GA affect your ranking/visibility in google search?

I totally like the idea to have a simple stat for posts read - from that basic stat one can decide to go with a solid webstat solution like GA or have a self hosted solution like piwik for example.

2 Likes

Hi, bumping this topic a bitā€¦

Using GA has several additional drawbacks apart from handing data over to 3rd party. Loading additional resources in regards to external JS and therefore more HTTP(S) requests are slowing down the load performance of the page, even while using the new async Google Tag Manager (gtag.js). And on top of that Google somehow violates there own recommendations of Lighthouse in regards to content caching.

Having a simple view counter within Ghost would open new possibilities in regards to displaying short lists, like ie. ā€œMost Read Storiesā€. I find this functionality quite interesting and know it from Joomla CMS.

As for more full-fledged analytics, I second GoAccess as the tool of choice but that is unrelated to Ghost itself, as GoAccess parses the web server log files directly to produce the reports.

So long, JoKi

2 Likes

I missed exactly the same pointed by @webbhostnet @ponnuki and @jochenkirstaetter and thatā€™s why I built Ghostboard as specific analytics for Ghost, maybe someone find it interesting

5 Likes

Thanks for this!

If youā€™re not web dev friendly itā€™s fairly simple as far as adding it manually with Ghost (using the default Casper v2.9.1). Since youā€™re adding a custom file, you just add your custom private.hbs file to the content/themes/casper directory of your Ghost installation (make a copy from that directory while the feature is enabled). Iā€™ve included mine below with the GAID excluded:

<!doctype html>
<!--[if (IE 8)&!(IEMobile)]><html class="no-js lt-ie9" lang="en"><![endif]-->
<!--[if (gte IE 9)| IEMobile |!(IE)]><!--><html class="no-js" lang="en"><!--<![endif]-->
    <head>
        <meta http-equiv="Content-Type" content="text/html" charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

        <title>{{@blog.title}} - Private Site Access</title>

        <meta name="HandheldFriendly" content="True">
        <meta name="MobileOptimized" content="320">
        <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-capable" content="yes" />

        <link rel="shortcut icon" href="{{asset "favicon.ico"}}">
        <meta http-equiv="cleartype" content="on">

        <link rel="stylesheet" href="{{asset "public/ghost.css" hasMinFile="true"}}"/>

        <!-- Global site tag (gtag.js) - Google Analytics -->
        <script async src="https://www.googletagmanager.com/gtag/js?id=YOUR-GAID"></script>
        <script>
          window.dataLayer = window.dataLayer || [];
          function gtag(){dataLayer.push(arguments);}
          gtag('js', new Date());

          gtag('config', 'YOUR-GA');
        </script>
    </head>
    <body>
        <div class="gh-app">
            <div class="gh-viewport">
                <main class="gh-main" role="main">
                    <div class="gh-flow">
                        <div class="gh-flow-content-wrap">
                            <section class="gh-flow-content">
                                <header>
                                    <h1>This site is private</h1>
                                </header>
                                <form class="gh-signin" method="post" novalidate="novalidate">
                                    <div class="form-group{{#if error}} error{{/if}}">
                                        <span class="gh-input-icon gh-icon-lock">
                                            <svg version="1" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><g><path d="M12 14c-.552 0-1 .449-1 1 0 .365.207.672.5.846v2.654c0 .276.224.5.5.5s.5-.224.5-.5v-2.654c.293-.174.5-.481.5-.846 0-.551-.448-1-1-1zM20.5 9h-2.5v-3c0-3.309-2.691-6-6-6s-6 2.691-6 6v3h-2.5c-.276 0-.5.224-.5.5v14c0 .276.224.5.5.5h17c.276 0 .5-.224.5-.5v-14c0-.276-.224-.5-.5-.5zm-13.5-3c0-2.757 2.243-5 5-5s5 2.243 5 5v3h-10v-3zm13 17h-16v-13h16v13z"/></g></svg>
                                            {{input_password class="gh-input" placeholder="Password"}}
                                        </span>
                                    </div>
                                    <button class="gh-btn gh-btn-blue gh-btn-block" type="submit"><span>Enter Now</span></button>
                                </form>

                                {{#if error}}
                                    <p class="main-error">{{error.message}}</p>
                                {{/if}}
                            </section>
                        </div>
                    </div>
                </main>
            </div>
        </div>
    </body>
</html>

Once you have that saved with your GAID on line 21 and 27 you will need to restart Ghost and should be active from there. Alternatively you could add the handlebar call for

{{ghost_head}}

This should work in general Iā€™d presume, but your mileage may vary :slight_smile:

Iā€™m using GoAccess, but struggling to get real-time html reports to show in the browser. Have you had any luck with this in conjunction with Ghost?

Yes, it works fine with Ghost (or anything else running on/with a webserver really, as it just parses the access log).

For the realtime stats to work, you need to get the websockets server working and preferably reverse-proxy it with nginx (or your webserver of choice) so that itā€™s available on https/443.

When itā€™s working properly, the little green indicator on the left of the stats page will remain ā€˜litā€™ and youā€™ll be able to see your stats updating without refreshing the page, as you click through links on your Ghost blog.

+1 for Ghostboard!

Itā€™s built specifically for Ghost blogs. No cookies, GDPR compliant. You can see your most popular tags, you get some nice SEO tips such as ā€œthis blogpostā€™s URL is a bit too longā€. You get average word count and more. Deffo the better choice. It costs $9 a month ($7 if billed annually).

Not related to dev or anything, just a user :)

4 Likes

It sounds interesting, maybe too expensive for a blogger who writes just for fun. In my opinion there should be a free version with maybe a few features.

Does Ghost will do something similar natively?

In my humble Opinion, something like Statify (Statify ā€“ WordPress-Plugin | WordPress.org Deutsch) from WordPress would be a neat and reliable Solution to the Problem, converted for Ghost and with better implementation in Terms of (maybe?) using another DB for itā€™s work or something like that.

I personally donā€™t like the Fact to store all of the collected Data from an Analytics Plugin/App within the same Database because it creates a Mess.

Donā€™t know how this could made possible, just an idea.