Skip to content Skip to sidebar Skip to footer

How To Track A Google Analytics Custom Event On An Embedded Form?

I have a form that is embedded on my site via JavaScript. How can I track a custom event in Google Analytics when that form is submitted? I have a form them is embedded in my site

Solution 1:

Make sure your jquery library supports the on function (1.7+) and that you're attaching the event after the DOM is ready by using the document ready syntax. The following worked fine for me:

<script src="https://app.convertkit.com/landing_pages/531.js?orient=horz"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type='text/javascript'>
$(function(){
  $('#ck_subscribe_form').on('submit',function(){
    console.log('testing google anayltics custom event');
    _gaq.push(['_trackEvent', 'Newsletter', 'Subscribe', 'Freelance Pricing Handbook']);
  });
});
</script>

Post a Comment for "How To Track A Google Analytics Custom Event On An Embedded Form?"