Coder Social home page Coder Social logo

kirby-google-analytics's Introduction

Google Analytics plugin for Kirby 2

What is it?

Runs Google Analytics as soon as the site is not running on localhost and the Do Not Track header is not set by the browser.

Why use it?

I maded it because I often forgot to (re)activate the Google Analytics snippet after a site went live.

How to use it?

Add it as a submodule using git: git submodule add https://github.com/iksi/kirby-google-analytics.git site/plugins/kirby-google-analytics or put the contents of the repository in a folder called analytics in /site/plugins.

Next add a Google Analytics tracking ID to your configuration. The tracking ID is a string like UA-000000-01. You can also set anonymize to false to disable IP anonymization (the default is true).

c::set('plugin.googleAnalytics', true);
c::set('plugin.googleAnalytics.trackingId', 'UA-000000-01');
c::set('plugin.googleAnalytics.anonymizeIp', false);

Instead of a string you can also provide a callback function for the tracking ID:

c::set('plugin.googleAnalytics.trackingId', function() {
  return site()->googleAnalyticsTrackingId()->value();
});

You can add it to your website as a snippet:

<?php snippet('google-analytics') ?>

Author

Jurriaan Topper, [email protected] (http://www.iksi.eu/)

kirby-google-analytics's People

Contributors

iksi avatar

Stargazers

 avatar Alex Piacentini avatar Martin Thiemann avatar Mathieu Etienne avatar Ken Verhaegen avatar  avatar Andreas Bilz avatar Mohammad Shiran avatar Sander avatar Brent Cartier avatar Graham Harper avatar

Watchers

James Cloos avatar  avatar

kirby-google-analytics's Issues

Rename plugin folder

You should put the plugin into a folder named analytics or else add a step to your installation instructions to get the user to rename the folder themselves. I just spent a while debugging wondering why the plugin wasn't loading, I didn't know the folder had to have the same name as the PHP file within.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.