Highlighted

Getting the value of selected radio button and assigning it as a label of a Google Event

Gold Contributor
Gold Contributor

Hi!

There's are 3 radio buttons with the name payment[method] and the user selection has to be captured and assigned to a Google Analytics event as a label when the user clicks the submit button..  So I have this code in the Custom option of the onclick handler extension listening to the mousedown on the submit button.

b["js_page.ga_eventCategory"]="Click Tracking";
b["js_page.ga_eventAction"]="Payment Method";
b["js_page.ga_eventLabel"]= jQuery("input(name='payment[method]'):checked").val();

The event is not firing.  If I comment out the label line it goes on an infinite processing loop.  If I try this in the link option also only the event is firing but the label is 'not set'.    Is there anything wrong in my code?  I tried to get the value on the onHandler code listening to a mousedown on all radio buttons with the name payment[method] but no success there as well.   Also, am I to understand console.log does not work for DOM Ready extensions?  Then how do I test the code? Any suggestions?  Thanks a lot!

Sujani

1 REPLY 1
Highlighted

Getting the value of selected radio button and assigning it as a label of a Google Event

Gold Contributor
Gold Contributor

Hi @sujani_koya ,

       Its been week, you would have resolved the issue, if not there is an error in jQuery syntax.

Your syntax:

jQuery("input(name='payment[method]'):checked").val();

Syntax should be

jQuery("input[........]:checked").val();

instead of round brackets you should use square brackes.

 

Thanks

Its Not Who I am Underneath, but What I Do That Defines Me