PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Coupon Code Tracking with Google Analytics

  1. mjeune
    Member

    I created a form which contains a coupon field in it. How would I go about tracking the coupon codes entered in this field (as visitors fill out and submit the form) in Google Analytics? I am not looking to validate the codes, I'm simply wanting to track whatever code is entered in GA. Is this possible? If yes, how?

    Posted 6 years ago on Thursday December 13, 2012 | Permalink
  2. This is a question for the Google Analytics experts. We have no specific information about tracking in Google Analytics. Gravity Forms will collect the data. Customization beyond that point is up to you.

    http://productforums.google.com/forum/#!forum/analytics

    Posted 6 years ago on Thursday December 13, 2012 | Permalink
  3. mjeune
    Member

    I read the Google forums about this and I think I found a solution, but the solution requires that some JavaScript code be attached to the coupon field:

    onchange="pageTracker._trackEvent('Coupons', this.form.action, this.value);"

    How do I go about attaching this JS code to the field?

    Posted 6 years ago on Thursday December 13, 2012 | Permalink
  4. How are your coupons being added to the form?

    Posted 6 years ago on Thursday December 13, 2012 | Permalink
  5. mjeune
    Member

    Manually, the user types them in.

    Posted 6 years ago on Thursday December 13, 2012 | Permalink
  6. I see. The form field exists and the visitor enters their coupon code. You want to track what they enter. Try adding this jQuery to an HTML field in your form:

    <script type="text/javascript">
      jQuery('#input_229_1').change(function() {
        alert('.change() called for field 229_1');
        pageTracker._trackEvent('Coupons', this.form.action, this.value);
      });
    </script>

    The coupon field in my form #229 is field 1, which is why line 2 has "input_229_1" - update this to the field where your coupon code is being entered.

    You can remove the "alert" line once you are sure this code is being executed.

    This should work if Google Analytics is present on the page. Let us know if you need help. Please provide a link to your form online if you need additional assistance.

    Posted 6 years ago on Friday December 14, 2012 | Permalink
  7. mjeune
    Member

    The alert worked fine, but can't locate the entry in GA. Probably have to wait a little bit. Will let you know.

    Posted 6 years ago on Friday December 14, 2012 | Permalink
  8. It may take a little while to show up. Please let us know if it is working or not.

    Posted 6 years ago on Wednesday December 19, 2012 | Permalink