GithubHelp home page GithubHelp logo

designcity / silverstripe-google-analytics Goto Github PK

View Code? Open in Web Editor NEW

This project forked from creativeidea/silverstripe-google-analytics

0.0 3.0 0.0 215 KB

Extension to add Google Analytics tracking code to SilverStripe 3

License: MIT License

PHP 75.49% JavaScript 24.51%

silverstripe-google-analytics's Introduction

Google Analytics tracking code for SilverStripe 3

Extension to add Google Analytics tracking code to your SilverStripe templates.

It includes tracking for all external links & "assets" downloads using pure JavaScript, so no external libraries are needed.

Features

  • Unobtrustive tracking - attaches to document.body.onclick and monitors all clicks at time of click, rather than on page load (ie: works with links including those generated by Ajax etc on the page after page load).
  • File downloads (from the assets folder) are tracked as events "Downloads".
  • Outgoing links are tracked as events "Outgoing Links".
  • Tracking for both outgoing links and downloads have built-in (500ms) delay if no target is set to allow for GA tracking.
  • Tracking of 404 & 500 page errors (tracked as an events) - Note: you must Save & Publish both your error pages after module installation.
  • Development mode is commented out to prevent false tracking. It only actually works in live mode.

Requirements

  • SilverStripe 3+

Usage

In your _config.php or _ss_environment.php add your GA tracking code

define('GaTrackingCode', 'UA-xxxxxx');

as well as an optional secondary tracker

define('GaTrackingCodeSecondary', 'UA-yyyyyy');

To include tracker with external JavaScript resource (download/outgoing tracking), simply add

$GoogleAnalytics

or to include tracker and download/outgoing tracking inline, simply add

$GoogleAnalyticsInline

To start tracking, make sure your website is in Live mode

define('SS_ENVIRONMENT_TYPE', 'live');

silverstripe-google-analytics's People

Contributors

axllent avatar

Watchers

James Cloos avatar Ryan Cotter avatar Design City avatar

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.