Skip navigation
new2oop
Currently Being Moderated

How do I pass a form value to Google Analytics

Jul 29, 2012 5:12 AM

I would like to pass a form value to Google Analytics. ie. if the user enters a value and submits the form, on the confirmation page I'd like to read the value and other form fields and pass those populate the Google Analytics tracking code ie. populate this withthe form values:

 

_gaq.push(['_addItem',
     
'1234',         // order ID - necessary to associate item with transaction
     
'DD44',         // SKU/code - required
     
'T-Shirt',      // product name - necessary to associate revenue with product
     
'Olive Medium', // category or variation
     
'11.99',        // unit price - required
     
'1'             // quantity - required
  
]);

 
Replies
  • Currently Being Moderated
    Jul 29, 2012 11:15 AM   in reply to new2oop

    How about this - bind an ajax call to google analytics to the form submit button (change the type from submit to button or suppress the default event), having the form itself only submit after the ajax call is successful? No need to even worry about the confirmation page then.

     
    |
    Mark as:
  • Liam Dilley
    6,691 posts
    Feb 28, 2012
    Currently Being Moderated
    Jul 29, 2012 1:47 PM   in reply to kenneth_rapp

    Google won't pick that up Kenneth.

    Custom conformation page, pass variables through via the URL and use the URL module to fetch those and popular the analytics values.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points