Analytics
1.7K members online now
1.7K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

Onsubmit event tracking via dataLayer doesn't work

Follower ✭ ☆ ☆
# 1
Follower ✭ ☆ ☆

Hello, everyone!

 

Here's my sad storySmiley Happy

I need to track from submissions on page site.ru/php/#hr:registerWizard.php?company=_

 

So for the form I've implemented tracking code this way

 

<form enctype="application/x-www-form-urlencoded" class="form_data_list" target="iframe-uploader" method="post" action="/propartner/php/registerWizard.php?company=step3" onsubmit="dataLayer.push({'event':'PPEvent','eventCategory':'OnpageTracking','eventAction':'Apply as a new partner','eventLabel':'Registered'});">

 

 

But event is not being tracked at all. I'm about to lose my mind

Probably the problem is about hash in page's uri? I never faced websites with such ones.

 

Thank you in advance!

1 Expert replyverified_user
1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author Anna A
July 2016

Re: Onsubmit event tracking via dataLayer doesn't work

Top Contributor
# 6
Top Contributor

Hi,

 

If you set up Google Analytics through Google Tag Manager you need to track the events also through GTM. Your code snippet pushes the event to dataLayer, and there should be a tag set up in GTM that is fired on your event and collects the event details. If you set up Google Analytics using the tracking script from the GA admin, you need to use a different code:


https://developers.google.com/analytics/devguides/collection/analyticsjs/events

 

Your code will look like this:

 

<form enctype="application/x-www-form-urlencoded" class="form_data_list" target="iframe-uploader" method="post" action="/propartner/php/registerWizard.php?company=step3" onsubmit="ga('send', 'event', 'OnpageTracking','Apply as a new partner', 'Registered');">

 

Let me know if you have more questions.


Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital

View solution in original post

Re: Onsubmit event tracking via dataLayer doesn't work

Visitor ✭ ✭ ✭
# 2
Visitor ✭ ✭ ✭
Hey,
I might be wrong, but would you just push event name to dataLayer instead and after that capture this event in GTM?
Some tutorial http://www.simoahava.com/gtm-tips/add-the-event-key-to-datalayer-pushes/#gref
I have never pushed events info like action and label to dataLayer since I thought it is only an impulse going to GTM.

Re: Onsubmit event tracking via dataLayer doesn't work

Top Contributor
# 3
Top Contributor
Hi Anna,

Did you set up the event tracking tag in Google Tag Manager?
See step one in the document below:
https://support.google.com/analytics/answer/6164470?hl=en
Hope this helps.

Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital

Re: Onsubmit event tracking via dataLayer doesn't work

Follower ✭ ☆ ☆
# 4
Follower ✭ ☆ ☆
Well, actually I meant to set up tracking code hardcoded ( This option worked normally with other websites.

Re: Onsubmit event tracking via dataLayer doesn't work

[ Edited ]
Follower ✭ ☆ ☆
# 5
Follower ✭ ☆ ☆

I did not, because don't appreciate tracking form submissions via Google tag Manager.

Marked as Best Answer.
Solution
Accepted by topic author Anna A
July 2016

Re: Onsubmit event tracking via dataLayer doesn't work

Top Contributor
# 6
Top Contributor

Hi,

 

If you set up Google Analytics through Google Tag Manager you need to track the events also through GTM. Your code snippet pushes the event to dataLayer, and there should be a tag set up in GTM that is fired on your event and collects the event details. If you set up Google Analytics using the tracking script from the GA admin, you need to use a different code:


https://developers.google.com/analytics/devguides/collection/analyticsjs/events

 

Your code will look like this:

 

<form enctype="application/x-www-form-urlencoded" class="form_data_list" target="iframe-uploader" method="post" action="/propartner/php/registerWizard.php?company=step3" onsubmit="ga('send', 'event', 'OnpageTracking','Apply as a new partner', 'Registered');">

 

Let me know if you have more questions.


Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital

Re: Onsubmit event tracking via dataLayer doesn't work

Follower ✭ ☆ ☆
# 7
Follower ✭ ☆ ☆
Oh, we really missed necessary settings in GTM Smiley Happy
Thank you so much, I'm going to get down fixing that situation Smiley Happy