Some Advanced Tracking in Google Analytics in 5 mins - PhillyJS meet up

Post on 21-Oct-2014

340 views 0 download

Tags:

description

 

transcript

Some Advanced

Tracking in Google

Analytics

...with JavaScript, of course!

I’m Nico

I work at SEER Interactive

I do technical analytics implementation

I also run some SEO projects

I like JavaScript & R and a lil’ bit of python

But Mostly...

I LIKE DATA …and like collecting it

You need Async or Universal Code

<script type="text/javascript">

var _gaq = _gaq || [];

_gaq.push(['_setAccount', 'UA-XXXXX-X']);

_gaq.push(['_trackPageview']);

(function() {

var ga = document.createElement('script'); ga.type = 'text/javascript';

ga.async = true;

ga.src = ('https:' == document.location.protocol ? 'https://ssl' :

'http://www') + '.google-analytics.com/ga.js';

var s = document.getElementsByTagName('script')[0];

s.parentNode.insertBefore(ga, s);

})();

</script>

Event Tracking

_gaq.push(['_trackEvent',

'Videos',

'Play',

'B-day'

5]);

Google

Documentation:

nnii.co/19QcDBV

Event Tracking

_gaq.push(['_trackEvent',

'Videos', // category

'Play', //action

'B-day' //label

5]); // value

Google

Documentation:

nnii.co/19QcDBV

Custom Variables

Cookie the visitor.

Bucket them based on an

action.

Segment them

Tell me what they do

compared to other people

Custom Variables

_gaq.push(['_setCustomVar',

1,

'Items Removed',

'Yes',

2

]);

Custom Variables

_gaq.push(['_setCustomVar',

1, // slot #1.

Required

'Items Removed', // Category for the user

activity. Required

'Yes', // value of the custom variable.

Required.

2 // Sets the scope to

session-level. Optional

]);

Scope

3 Cool Things to Track

How do people use your form?

What links are getting clicked on the most?

Are people readers or scanners?

Are people clicking on my links?

You should make sure its getting downloaded,

viewed and visited.

Full post: nnii.co/ext-links-tracking

Post credit: Blast Marketing

$('a').click(function(){

//only external links

_gaq.push(['_trackEvent','Ext-links',

'clicked','External']);

});

Credit: Blast Analytics

What are people REALLY doing on

this page?

Form Tracker

var array1 = [];

$(document).ready(function () {

$('input').change(function () {

var formbox = $(this).attr('id');

array1.push(formbox);

console.log("you filled out box " + array1);

});

$('#submit').click(function () {

console.log('tracked ' + array1);

alert('this is the order of boxes you filled out: '

+ array1);

//_gaq.push(['_trackEvent', 'Form', 'completed', '"'

+ array1 + '"']);

});

});

JS Fiddle:

nnii.co/js-adv-form-tracker

Output - Form Tracker

JS Fiddle: nnii.co/js-adv-form-tracker

What Does This Say?

About 82% that load the article start reading (daily

avg = 82%)

About 55% make it to the bottom of the content

(daily avg = 63%)

About 14% make it to the bottom of the page (daily

avg = 18%)

THANKS!

Have fun with it!

Twitter: @nicomiceli

G+: gplus.to/nicomiceli

Presentation:

nnii.co/js-meetup-track