Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Analytics isn't reporting #26

Open
kbarre123 opened this issue Oct 6, 2014 · 1 comment
Open

Google Analytics isn't reporting #26

kbarre123 opened this issue Oct 6, 2014 · 1 comment

Comments

@kbarre123
Copy link

Has anyone else been successful in implementing Google Analytics with the existing code?

I've compared the app/views/layouts/_analytics.html.haml with the code on the Google Developer page, and there's a difference. Where Google's has:

$(document).on('page:change', 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);
  });

There is only:

$(document).on('page:change', function(){
    _gaq.push(['_trackPageview'])
});

I've added my property's analytics code as an environmental variable on Heroku, as I've done with many other sites, but this doesn't seem to be working.

@simple10
Copy link
Member

Any analytics packages have to be handled in a special way due to Turbolinks. The Google Analytics script should already be loaded in the page before the _gaq.push is triggered.

Double check that you have analytics configured in config/analytics.yml. If a Google Analytics key is provided, the script should automatically be injected for you.

Please let me know if this works. It could be a regression bug, but it used to be working just fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants