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

Multiple Trackers, per domain #10

Closed
filipebarcos opened this issue Nov 3, 2014 · 1 comment
Closed

Multiple Trackers, per domain #10

filipebarcos opened this issue Nov 3, 2014 · 1 comment

Comments

@filipebarcos
Copy link

Hi,

Is there a way I can configure multiple trackers, depending on domain?

config.middleware.use(Rack::Tracker) do
  handler :google_analytics, { tracker: 'XXXXX', cookieDomain: 'example.com' }
  handler :google_analytics, { tracker: 'YYYYY', cookieDomain: 'another.com' }
end

Maybe not this way, but something I can be capable to do this. My case, I have the one website, with 2 brands, depending on domain, today I load different tracker, since I'm using the common js solution (snippet on my page)

@kangguru
Copy link

kangguru commented Nov 5, 2014

unfortunately not, but the tracker can be set dynamically during a request, so you might be able to to something like this:

config.middleware.use(Rack::Tracker) do
  handler :google_analytics, { tracker: Proc.new{|e| e[:host] == "example.org" ? "XXXXX" : "YYYYY" }}
end

thats not very elegant, but it might serve your purpose. i'm not sure where the host hides in the env-hash, but its in there ... somewhere ;)

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

3 participants