Simple ghost stats/analytics


#1

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.


#2

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:


#3

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.


#4

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


#5

Another self hosted analytics would be Fathom.


#6

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


#7

The team I’m currently working with are looking at using ahoy (ruby), which is what Instacart uses. https://github.com/ankane/ahoy

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.


#8

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:


#9

I’d recommend it too. I have been using it for a while now.


#10

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.


#11

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


#12

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.


#13

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


#14

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


#15

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: