I would like to do some analytics on my active admin enabled rails application. For that, I need to paste some <script>
and <noscript>
code just before the </body>
tag in my layout file. Unfortunately, I am not able to do that as the application.html
layout file seems ineffective since ActiveAdmin renders its own layout files.
Is there a hook/place where I can insert the custom html code ?
Tested with ActiveAdmin 0.6.0 and Rails 4.0.5.
You can also override the arbre view used by active admin to render the footer. In your active_admin
initializer add:
# config/initializers/active_admin.rb
require 'admin/analytics_footer'
ActiveAdmin.setup do |config|
config.namespace :admin do |admin|
config.view_factory.footer = Admin::AnalyticsFooter
end
end
And define the view:
# lib/admin/analytics_footer.rb
module Admin
class AnalyticsFooter < ActiveAdmin::Views::Footer
def build
super
render('layouts/analytics')
end
end
end
And place your ga tracking code in app/views/layouts/_analytics.html.erb
. After a server restart the snippet should appear inside the footer at the end of the page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With