Skip to content

Instantly share code, notes, and snippets.

@measureschool

measureschool/Form Fill Demo Secret

Created May 19, 2020
Embed
What would you like to do?
This is a custom HTML tag for GTM that fills out a form field with the data provided by a variable
<script>
(function () {
var value = "{{cookie - __gtm_campaign_url}}" //fill with variable which information should be written into the field
var selector = "input[name='source']" //fill with CSS Selector that identifies the form field
var field = document.querySelector(selector)
if(field){ field.value = value; }
})();
</script>
<script>
(function () {
var value = "" //fill with variable which information should be written into the field
var selector = "" //fill with CSS Selector that identifies the form field
var field = document.querySelector(selector)
if(field){ field.value = value; }
})();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment