Google Tag Manager - Fire GA event on form field focus not getting to GA -
i trying create google analytics event google tag manager when user focuses on form field. not able event show in google analytics account , unsure cause is, have reviewed each step , of code , gtm setup seem correct.
my tag manager account working many other tags already.
here form code:
<div class="fancybox_form"> <form action="http://cl.exct.net/subscribe.aspx?lid=7135602" method="post" id="subscribe"> <p style="margin: 5px; padding: 0;">* required fields</p> <div class="row"> <p class="column large-8 small-16"><label for="">first name</label><br> <input class="textfield" type="text" name="first name" required=""></p> <p class="column large-8 small-16"><label for="">last name</label><br> <input class="textfield" type="text" name="last name" required=""></p> </div> <div class="row"> <p class="column large-16 small-16"><label for="">email address *</label><br> <input class="textfield" type="email" name="email address" required=""></p> </div> <div style="display: none;"><input class="textfield" type="text" name="subscription source" required="" value="win"></div> <div class="row"> <p class="submit_container"><input class="button" type="submit"></p> <p class="column large-16 small-16">we never give away information third parties. see our <a href="http://www.renown.org/disclaimer" target="_parent">privacy policy</a></p> <p><input type="hidden" name="mid" value="207548"><br> <input type="hidden" name="thx" value="http://r-bestmedicine.org"><br> <input type="hidden" name="err" value="http://r-bestmedicine.org/wp-content/themes/rhealthnews/subscribe.php"></p> </div> </form> </div>
here code have in custom html tag fired on pages
firing rule -
{{url}} matches regex .*
tag code -
<script type="text/javascript"> $(document).ready(function(){ $('form#subscribe :input:first').focusin(function(){ datalayer.push({'event':'formfieldfocus'}); }); }); </script>
here classic google analytics tag push event datalayer google analytics
firing rule -
{{event}} equals formfieldfocus
tag -
tag type - classic google analtyics web property id - account id in macro track type - event category - formfieldfocus action - {{url}} label - {{referrer}}
any appreciated
your form, hosted in iframe, isn't loading jquery. add jquery library, , should work.
here js fiddle.
<script type='text/javascript' src='http://bestmedicinenews.org/wp-includes/js/jquery/jquery.js?ver=1.10.2'></script>
Comments
Post a Comment