user3787971
user3787971

Reputation: 457

Getting Google Analytics up in Rails 3 App

I've tried all the methods outlined Here for getting google analytics up and running on my rails app.

I think that google is talking to my app because when I inspect the elements and look at the network I see the .js file.

But I'm not seeing any data come in through realtime analytics on my account

I thought I might need to just sit and wait but this didn't work. I've now tried several ways to do this and nothing is working.

gemfile

source 'https://rubygems.org'

gem 'rails', '3.2.11'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
# For google analytics
gem 'google-analytics-rails', '1.0.0'

gem 'activeadmin'
gem 'pg'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

  gem 'uglifier', '>= 1.0.3'
end

group :development do
  gem 'pry'
end

gem 'rails_12factor' 
gem 'delayed_job_active_record'

gem 'unicorn'

I have this line in my head tag at the bottom.

<%= analytics_init if Rails.env.production? %>

I thought this was the problem so I removed the if statement but that seemed like a bad idea as it would allow google to track any environment.It still didn't work after this...

What am I missing? I've never had this problem with analytics before. Any suggestions?

Upvotes: 1

Views: 82

Answers (1)

JohnSalzarulo
JohnSalzarulo

Reputation: 1126

My guess is that you forgot to replace the placeholder within the analytics.js.coffee file.

@analyticsId: ->
    # your google analytics ID(s) here...
  'UA-XXXXXXX-XX'

Upvotes: 1

Related Questions