I have been tracking users with Google Analytics via the javascript code in the header of my main template and that works very well. I''ve come to realize that there are a few places where I have will_paginate and some cascading collections where there are partials that update but the entire page does not refresh and thus, even though the content is changed, the click activity is never recorded by Google and I am essentially cheating myself from the intelligence of what users actually are doing. Obviously I can re-locate the google javascript code for sending the reports to Google Analytics from the main template to the inner-most partial for each of my pages but that seems to be very redundant and not very dry so I''m wondering how do other people handle this? Is there a way to just execute when the partial is redrawn? Is it possible to use observers to refresh 2 divs on the same page? (albeit one in the main template and one in a partial)? Craig -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> I have been tracking users with Google Analytics via the javascript > code > in the header of my main template and that works very well. > > I''ve come to realize that there are a few places where I have > will_paginate and some cascading collections where there are partials > that update but the entire page does not refresh and thus, even though > the content is changed, the click activity is never recorded by Google > and I am essentially cheating myself from the intelligence of what > users > actually are doing. > > Obviously I can re-locate the google javascript code for sending the > reports to Google Analytics from the main template to the inner-most > partial for each of my pages but that seems to be very redundant and > not > very dry so I''m wondering how do other people handle this? Is there a > way to just execute when the partial is redrawn? Is it possible to use > observers to refresh 2 divs on the same page? (albeit one in the main > template and one in a partial)?Leave it where it is and use their API to "make a call". http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&answer=55521 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Mon, 2010-03-08 at 13:43 -0800, Philip Hallstrom wrote:> > I have been tracking users with Google Analytics via the javascript > > code > > in the header of my main template and that works very well. > > > > I''ve come to realize that there are a few places where I have > > will_paginate and some cascading collections where there are partials > > that update but the entire page does not refresh and thus, even though > > the content is changed, the click activity is never recorded by Google > > and I am essentially cheating myself from the intelligence of what > > users > > actually are doing. > > > > Obviously I can re-locate the google javascript code for sending the > > reports to Google Analytics from the main template to the inner-most > > partial for each of my pages but that seems to be very redundant and > > not > > very dry so I''m wondering how do other people handle this? Is there a > > way to just execute when the partial is redrawn? Is it possible to use > > observers to refresh 2 divs on the same page? (albeit one in the main > > template and one in a partial)? > > Leave it where it is and use their API to "make a call". > > http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&answer=55521---- yeah - thanks - I sort of came up with a better solution than that but I still was eager to see what others are doing. If I were to do what was suggested, that would unnecessarily inflate the numbers for the partial since it would send an update to GA even when the entire page was refreshed which was clearly what I didn''t want to do. So what I ended up doing was to take advantage of the session flash variable - for those who might search and find this thread later on... in the view (actually the deepest nested partial)... <% if flash[:analytics] -%> <script type="text/javascript"> try { var pageTracker = _gat._getTracker("UA-XXXXXXX_X"); pageTracker._trackPageview("<%=flash[:analytics]%>"); } catch(err) {} </script> <% end -%> and then I can properly provide flash[:analytics] value in the controller method that ultimately renders partial updates... flash[:analytics] = "/content/menu_topic=" + @menu_topic + "&page=" + params[:page].to_s which completely gives me the detail I am looking for in Google Analytics and without false reports when the entire page is loaded. On the whole, will_paginate is a very useful tool but when you want to paginate inside of partials, it requires you to be inventive. Thanks Craig -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.