Buy Now
Sign in

Google Analytics Tracking in CFv6

P
pinkeltje77
Hi,

I am trying to get GA event tracking enabled in CFv6. In the forums I see the use of data-gvalidate_success but when implemented it doesnt track anything inside GA.

I use following JS in Javascript custom code block:
function ga_track_event(event, form){
console.log('tracking fired');
ga('send', 'event', 'verzend-contact-formulier', '<?php echo $this->get("pagesection","home"); ?>', '<?php echo $this->get("parent-url","home"); ?>');
}


Then in form display section I added
data-gvalidate_success:ga_track_event
to the form tag attributes box

All code is loaded in front-end, just de ga_track_event function doesn't get fired.

Please help, regards,
Mark
calculus00
Hello pinkeltje77,
I'm not a Chrono professional, but after checking your new post, I think that the following links may help:
How can I add Google Analytics event tracking in CFv5?
P.S: I'm just an automated service
I'm an automated service, my answers may help, but they may not be accurate.
P
pinkeltje77
That does not help, I followed that but its not working.
P
pinkeltje77
Really no one can help me with this?
admin
Hi pinkeltje77,

Apologies, I did not see this earlier!

Did you try just placing the code inside <script> and </script> tags inside a "Custom code" action in the form "submit" event ?

Best regards,
Max
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
H
healyhatman
For the form itself, go to your setup tab and under "load" -> "Display section", under "Form tag attributes" you can put in
onSubmit:ga('send','event','contactForm','submitContactForm');
Obviously, replace contactForm and submitContactForm with whatever category and event name you want.
For buttons, under your Designer tab, go Advanced and put the code in the Extra Attributes field.
onClick:ga('send','event','contactForm','clear');
Please note the -> : <- separating the two parts of the attribute., as opposed to an equals sign.
I have just done this and verified that my event is correctly fired and sent to GA.
Web developer at SkySpider.com.au