3

I am trying to catch the UTM Params in the URL to add Source, Campaign etc to a User Account.
Sadly, I can't seem to figure out how to catch those params. As of know I following the Blog Article http://www.matthuggins.com/articles/tracking-new-user-registrations-by-source-search-terms

So, in my Application Controller I have following:

ApplicationController.class_eval do
  before_filter :capture_referrer

  protected
    def capture_referrer
      session[:referrer] = request.env['HTTP_REFERER'] if !session[:referrer]
    end
end

In the create Action in the user controller

@user.referrer = session[:referrer]

and in the USer Model itself:

 def set_traffic_source
  if self.referrer
    url = URI.parse(self.referrer)
    self.source ||= uri.host.downcase.gsub(/^www\./, '')
    self.traffic_keywords ||= search_termins(uri)
  end
end

This all works fine, for catching the referer - But I actualy want to read out the UTMs passed into by the URI. How would I go about this?

Martin Lang
  • 831
  • 11
  • 20
  • Please explain what you mean by "UTMs passed into by the URI"... i..e how the URI is actually constructed and used to make a request to the server. Could be a simple job just for `params`. – Ryan Bigg Oct 11 '12 at 20:25

1 Answers1

6

Use params to access them:

params[:utm_source]
params[:utm_campaign]
params[:utm_medium]
Ryan Bigg
  • 106,965
  • 23
  • 235
  • 261