javascript - alert()/datalayer.push are different -


i'm not experienced easy question 1 of you. i'm using google tag manager track time span element opened or closed on word press site(or trying @ least). relevant code , problem.

<script type="text/javascript">    datalayer.push({             eventaction: text              });     var text = jquery('span').click(function(){      var t = jquery(this).text();      alert(json.stringify(t));    }); </script> 

this triggered click contains ac_title_class.

the html class im targeting follows

<span class="ac_title_class">                             purpose                         </span> 

the problem code send [object object] google analytics instead of sending alert message says "/t/t/t/t/t/t/ purpose /t/t/t/t/t"(that inst says close). have tried countless different approaches , cant seem figure out. appreciate in advance. note: "ac_title_class" part of plugin.

you can push data layer data passing variable name , value eg. datalayer.push({'variable_name': 'variable_value'});

for check code below

<script type="text/javascript"> var text = jquery('span.ac_title_class').click(function(){     var t = jquery(this).text();     datalayer.push({eventaction: t }); }); </script> 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -