Subscription Tracking Code

Posted in: Newspaper
Post count: 80

Hi Guys

I hope you can help.

I am using Activecampaign and following their guide to set up a javascript that lets GA know when someone subscribes to my mailing list. The guide is here https://www.activecampaign.com/blog/how-to-setup-activecampaign-event-tracking#ac-form-to-ga-using-js

I have followed the guide and inserted the code into the customer code, customer Java script as instructed in the guide. here is the code:

var activeForms = document.getElementsByClassName(‘_form_1’);
var myForm = activeForms[0];

myForm.addEventListener(“submit”, () => {
console.log(‘The form was submitted’);
ga(‘send’, {
hitType: ‘event’,
eventCategory: ‘Category Baby Club’,
eventAction: ‘Action Signup’,
eventLabel: ‘Label Subscribe’
});
});

When i run a test the sign-up/subscribe works as normal but I am getting this error message in my console:

?vgo_ee=TwTWRGpFUlWyefAMi73qgYvy7T5YEJ8ohjC9vauJg30%3D:8497 Uncaught TypeError: Cannot read property ‘addEventListener’ of undefined
at ?vgo_ee=TwTWRGpFUlWyefAMi73qgYvy7T5YEJ8ohjC9vauJg30%3D:8497

It says cannot read properly ‘addeventlistener’on this line myForm.addEventListener(“submit”, () => {

Nothing is appearing in my GA.

Before I ask Active Campaign, I wanted to check I was placing this code in the right place in my Newspaper theme because their instructions ask that it goes on the page of the form just before the closing body tag.

Thanks
TS

Post count: 18283

Hello !

The code must be inserted in here: https://www.screencast.com/t/666LYaaGWMLS

Please make sure that you copy the correct code.

Thank you !

Post count: 80

Thanks Vald

Viewing 3 posts - 1 through 3 (of 3 total)
The forum ‘Newspaper’ is closed to new topics and replies.