Get information from form with custom JavaScript variables

1. Go to Tag Manager > Variables > Create new

2. Add this JavaScript

function() {
var field = {{Form Element}}.querySelector(‘[name=”X”]’);
return field ? field.value : undefined;

3. Use this custom variable when you are setting GA parameter for a tag.


Remember, that it is prohibited to store personal data to Google Analytics. So even if you could get someones name from the form for example, you are not allowed to that.