Monday, 8 May 2017

Send specific dataLayer to Google on Axios success response or error

Hi i'm used to send dataLayer to Google when form is submitted with Ajax. I do specific dataLayer.push if it success or fails. It's done on client side. Now i'm trying to do the same on node.js/express web app using axios library. But as axios works more on backend side i cannot send dataLayer. Would you have good idea to allow me to push datalayer in this case ?

Example of Axios post :

axios.post('/user', {
firstName: 'Fred',
lastName: 'Flintstone'
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});

Example of dataLayer

dataLayer.push({
'event' : 'GAEvent',
'eventCategory' : 'form',
'eventAction' : 'form submit',
'eventLabel' : '',
'eventValue' : 'success'
});



via Séb

No comments:

Post a Comment