Coder Social home page Coder Social logo

Dynamic trackers about rack-tracker HOT 11 CLOSED

railslove avatar railslove commented on May 22, 2024
Dynamic trackers

from rack-tracker.

Comments (11)

kangguru avatar kangguru commented on May 22, 2024

you can use a dynamic GA code like this:

config.middleware.use Rack::Tracker do
      handler :google_analytics, {
        tracker: lambda { |env| env['site_ga'] },
      }

and set the code in your controller like this

before_action do
  env[:site_ga] = "XXX"
end

from rack-tracker.

kangguru avatar kangguru commented on May 22, 2024

is that decent enough? :)

from rack-tracker.

DonSchado avatar DonSchado commented on May 22, 2024

pretty similar to this: #10

we should document this scenario ;)

from rack-tracker.

kangguru avatar kangguru commented on May 22, 2024

oh yea thx @DonSchado for giving a link ;) we should definitely document that!

from rack-tracker.

ruuts avatar ruuts commented on May 22, 2024

Aha clear. I think than it's still not possible to pass multiple GA id's to the tracker?
Like described in:

config.middleware.use(Rack::Tracker) do
  handler :go_squared, {
    trackers: {
      primaryTracker: 'ABCDEFGH',
      secondaryTracker: '1234567',
    }
  }
end

I don't see a construct like:
https://github.com/railslove/rack-tracker/blob/master/lib/rack/tracker/go_squared/template/go_squared.erb#L10
in:
https://github.com/railslove/rack-tracker/blob/master/lib/rack/tracker/google_analytics/template/google_analytics.erb

from rack-tracker.

kangguru avatar kangguru commented on May 22, 2024

hm, you want to have more than one tracker on a page?

from rack-tracker.

ruuts avatar ruuts commented on May 22, 2024

Yeah for example: https://app.bookingexperts.nl/nl/front/search/22:Go-Parcs?currency=EUR
Maybe server side calls like (gabba: https://github.com/hybridgroup/gabba) would better fit our use case.
Or should we extend https://github.com/railslove/rack-tracker/blob/master/lib/rack/tracker/google_analytics/template/google_analytics.erb to handle multiple trackers?

from rack-tracker.

kangguru avatar kangguru commented on May 22, 2024

yea. i see what you mean, so this is your use case then?

form what i see every tracker will then get the same events and tracks, correct? i assume this is a valid case then :) it will get hard if we want to send different events to different trackers.

are you interested in making a PR proposal?

from rack-tracker.

ruuts avatar ruuts commented on May 22, 2024

Yeah correct.
I'm interested but I first want to figure out the right tool for this issue.
Grabba might be something (looking into it now). If it's not what we want I think I will move to this.
Will let you know.

from rack-tracker.

kangguru avatar kangguru commented on May 22, 2024

cool 💃

its some years ago i was using gabba, so i cannot reason about it :)

from rack-tracker.

ruuts avatar ruuts commented on May 22, 2024

@kangguru just used a hybrid approach. Gabba for events / transactions. Client-side library for pageviews (to reduce external calls from our server)

Think it fits our use case better:

  1. Multi trackers
  2. Just ruby code, no javascript
  3. Handle event / transaction tracking in the controller which in my opinion is a better place than the views
  4. Easier to test

Downside of course:

  1. Rack-tracker is way more automatic.

I think rack-tracker will be a good fit for other projects of us so I will definitely use it at some point and hopefully make a contribution.

from rack-tracker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.