Reputation: 2823
I wish to have my datalayer push my event data dynamically. At the moment I need to change the statement manual however if I am to scale this up to 100 pages it can get annoying.
Is there a simple way to have the statement detect my URL path and populate the event with the path name ?
MktoForms2.whenReady(function (form) {
form.onSuccess(function (values, followUpUrl) {
pathname = window.location.pathname;
if (pathname == "/contact.html") {
dataLayer.push({event: 'Contact', eventLabel: form.getId()});
} else return null;
});
});
Upvotes: 0
Views: 510