uDAY
uDAY

Reputation: 31

Subscribe Form (Submit Event Tracking in Google Analytics)

I can't get Subscribe Form event tracking to submit button press on a site.

The relevant code is :-

Button Code

type="submit" and value="Subscribe"

<script>
document.addEventListener( 'submit', function( event ) {ga('Subscribe', 'event', 'Subscription Form', 'submit');}, false );
</script>

Upvotes: 0

Views: 250

Answers (2)

Max
Max

Reputation: 13334

Your code's wrong, the Subscribe method should be replaced with send to send events:

What you have:

ga('Subscribe', 'event', 'Subscription Form', 'submit');

What it should be:

ga('send', 'event', 'Subscription Form', 'submit');

And while you're at it, you might want to leverage the label field to provide more info such as the form id:

var form_id = ...; // some custom code to fetch form id from submit event
ga('send', 'event', 'Subscription Form', 'submit', form_id);

See doc for more info: https://developers.google.com/analytics/devguides/collection/analyticsjs/events

Upvotes: 1

XTOTHEL
XTOTHEL

Reputation: 5198

You need to change your code to:

gtag('event', 'submit', {
  'event_category' : 'Subscription Form',
});

Upvotes: 0

Related Questions