Fonziguy
2008-Jul-04 13:32 UTC
Using both href= and onclick=new Ajax.request to track outgoing links
Hi, I''m trying to track outgoing links on my site. When the user clicks on a link, I want them to be taken to the site (href) and I also want a background script call that records the link (via Ajax). The script I have worked in development mode but only works occasionally in production mode. Is it possible to link to a new site and call an ajax request at the same time? Thanks --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Diodeus
2008-Jul-04 14:29 UTC
Re: Using both href= and onclick=new Ajax.request to track outgoing links
Yup, like this: <a href="moo.htm" onclick="writeLog(''moo'');return false"> ...where writelog() is a function that does your Ajax call. Alternately, you can just get Google Analytics to log it: http://www.google.com/support/analytics/bin/answer.py?hl=en-ch&answer=55519 On Jul 4, 9:32 am, Fonziguy <lee.mun...-FhtRXb7CoQBt1OO0OYaSVA@public.gmane.org> wrote:> Hi, > > I''m trying to track outgoing links on my site. When the user clicks on > a link, I want them to be taken to the site (href) and I also want a > background script call that records the link (via Ajax). > > The script I have worked in development mode but only works > occasionally in production mode. > > Is it possible to link to a new site and call an ajax request at the > same time? > > Thanks--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Fonziguy
2008-Jul-04 16:36 UTC
Re: Using both href= and onclick=new Ajax.request to track outgoing links
Thanks for the reply Diodeus. I see what you''re saying, but won''t the return false stop the link from going to the href location? On Jul 4, 3:29 pm, Diodeus <diod...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Yup, like this: > > <a href="moo.htm" onclick="writeLog(''moo'');return false"> > > ...where writelog() is a function that does your Ajax call. > > Alternately, you can just get Google Analytics to log it: > > http://www.google.com/support/analytics/bin/answer.py?hl=en-ch&answer... > > On Jul 4, 9:32 am, Fonziguy <lee.mun...-FhtRXb7CoQBt1OO0OYaSVA@public.gmane.org> wrote: > > > Hi, > > > I''m trying to track outgoing links on my site. When the user clicks on > > a link, I want them to be taken to the site (href) and I also want a > > background script call that records the link (via Ajax). > > > The script I have worked in development mode but only works > > occasionally in production mode. > > > Is it possible to link to a new site and call an ajax request at the > > same time? > > > Thanks > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Fonziguy
2008-Jul-04 16:53 UTC
Re: Using both href= and onclick=new Ajax.request to track outgoing links
Thanks for the reply Diodeus. I see what you''re saying, but won''t the return false stop the link from going to the href location? On Jul 4, 3:29 pm, Diodeus <diod...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Yup, like this: > > <a href="moo.htm" onclick="writeLog(''moo'');return false"> > > ...where writelog() is a function that does your Ajax call. > > Alternately, you can just get Google Analytics to log it: > > http://www.google.com/support/analytics/bin/answer.py?hl=en-ch&answer... > > On Jul 4, 9:32 am, Fonziguy <lee.mun...-FhtRXb7CoQBt1OO0OYaSVA@public.gmane.org> wrote: > > > Hi, > > > I''m trying to track outgoing links on my site. When the user clicks on > > a link, I want them to be taken to the site (href) and I also want a > > background script call that records the link (via Ajax). > > > The script I have worked in development mode but only works > > occasionally in production mode. > > > Is it possible to link to a new site and call an ajax request at the > > same time? > > > Thanks > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Diodeus
2008-Jul-04 17:11 UTC
Re: Using both href= and onclick=new Ajax.request to track outgoing links
Nope, it does the opposite - it returns control to the link from being intercepted by Javascript. On Jul 4, 12:36 pm, Fonziguy <lee.mun...-FhtRXb7CoQBt1OO0OYaSVA@public.gmane.org> wrote:> Thanks for the reply Diodeus. > > I see what you''re saying, but won''t the return false stop the link > from going to the href location? > > On Jul 4, 3:29 pm, Diodeus <diod...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Yup, like this: > > > <a href="moo.htm" onclick="writeLog(''moo'');return false"> > > > ...where writelog() is a function that does your Ajax call. > > > Alternately, you can just get Google Analytics to log it: > > >http://www.google.com/support/analytics/bin/answer.py?hl=en-ch&answer... > > > On Jul 4, 9:32 am, Fonziguy <lee.mun...-FhtRXb7CoQBt1OO0OYaSVA@public.gmane.org> wrote: > > > > Hi, > > > > I''m trying to track outgoing links on my site. When the user clicks on > > > a link, I want them to be taken to the site (href) and I also want a > > > background script call that records the link (via Ajax). > > > > The script I have worked in development mode but only works > > > occasionally in production mode. > > > > Is it possible to link to a new site and call an ajax request at the > > > same time? > > > > Thanks--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Jarkko Laine
2008-Jul-04 21:00 UTC
Re: Using both href= and onclick=new Ajax.request to track outgoing links
On 4.7.2008, at 20.11, Diodeus wrote:> > Nope, it does the opposite - it returns control to the link from being > intercepted by Javascript.Err, no, it doesn''t. It stops the link from being followed. I even had to test this in a browser to make sure I''m not imagining things: <a href="http://google.com" onclick="console.log(''Testing''); return false;">Test</a> That certainly doesn''t go anywhere. Using true instead does lead to google. //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi
Walter Lee Davis
2008-Jul-05 16:56 UTC
Re: Using both href= and onclick=new Ajax.request to track outgoing links
On Jul 4, 2008, at 5:00 PM, Jarkko Laine wrote:> On 4.7.2008, at 20.11, Diodeus wrote: > >> >> Nope, it does the opposite - it returns control to the link from >> being >> intercepted by Javascript. > > Err, no, it doesn''t. It stops the link from being followed. I even > had to test this in a browser to make sure I''m not imagining things: > >Maybe if your log action returned true, you could do onclick="return console.log(''Testing'');" Walter --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Jarkko Laine
2008-Jul-05 20:02 UTC
Re: Using both href= and onclick=new Ajax.request to track outgoing links
On 5.7.2008, at 19.56, Walter Lee Davis wrote:> > On Jul 4, 2008, at 5:00 PM, Jarkko Laine wrote: > >> On 4.7.2008, at 20.11, Diodeus wrote: >> >>> >>> Nope, it does the opposite - it returns control to the link from >>> being >>> intercepted by Javascript. >> >> Err, no, it doesn''t. It stops the link from being followed. I even >> had to test this in a browser to make sure I''m not imagining things: >> >> > > Maybe if your log action returned true, you could do > > onclick="return console.log(''Testing'');"Sure, but that wasn''t the point :-) The point was that true let''s the browser to follow the link, false stops it. The log msg was there just for me to see that the js was executed. //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi