google analytics snippets

Using Garb to get unique pageviews per page from Google Analytics

Tagged google analytics, garb, ruby  Languages ruby
require 'rubygems'
require 'garb'

CA_CERT_FILE = "cacert.pem"

username = ""
password = ""
profile = "UA-xxx"

Garb::Session.login(username, password, :secure => true)

class Report
  extend Garb::Resource

  metrics :unique_pageviews
  dimensions :page_path
  sort :unique_pageviews.desc
  filters do
    contains(:page_path, '/xxx')

profile = Garb::Profile.first(profile)
options = {
  :start_date => ( - 365*5),
  :end_date =>
result = Report.results(profile, options)

result.each do |r|
  print "#{r.page_path} #{r.unique_pageviews}"

Problems with _gaq.push and _trackEvent?

Tagged _gaq, google analytics, _trackevent  Languages javascript

Problems with _gaq.push and _trackEvent?

  1. Check JavaScript/Firebug console for errors.
  2. Check that all values are in supported format, e.g. the value parameter must be an integer
  3. Use the queue to postpone or perform actions in sequence:
_gaq.push(function() {
      document.location = ''