Get a free 30 day trial of Perspective HERE.
If you don’t have a GTM container setup with Adsmurai installed for Meta CAPI integration, watch THIS video first.
In this video we’re going to use the existing ‘ajs_user_traits’ local storage variable that populates with form data once it’s been submitted.
Ensure GTM is installed before you continue.
To create a variable for a users email address; create a new ‘Custom JavaScript’ variable in GTM with the following code:
function() {
try {
var traits = JSON.parse(localStorage.getItem('ajs_user_traits'));
return traits && traits.email ? traits.email : undefined;
} catch (e) {
return undefined;
}
}Save the variable and publish the container.
Test the funnel in tagassistant. Once you submit the form, you should see a variable in tagassistant populated with the users email address.
To create another variable for another field on the form, you can edit the ‘traits.email’ part of the code above to match the parameter you require.
You can find a full list of the form fields and their identifiers by viewing the local storage ajs_user_traits variable and choosing one of the items listed in the JavaScript object.
You can access this information by going to Inspector > Application > Local storage > Select your domain > click on the ajs_user_traits variable.