Friday 15 February 2013

javascript - Custom Script in 'Conditions' section of Event Based Rule in DTM -



javascript - Custom Script in 'Conditions' section of Event Based Rule in DTM -

i trying utilize custom script in event based rule fire tag in dynamic tag management. please note objective fire tag on page of now, can leverage script farther utilize in dtm.

please have @ problem statement: in 'conditions' section of 'event based rules', have selected 'event type' 'click'. set 'element tag or selector' 'div'. now, can utilize 'manually assign properties & attributes' alternative here, eg: setting 'property' 'id' , 'value' '12345' (which id's value on page, suppose). so, whenever user clicks on link html element tag 'div' having property 'id' , value beingness '12345', omniture tag fire on click functionality of this.

what want is, instead of using 'manually assign properties & attributes' option, similar thing want writing script (in rule conditions -> info -> customs). writing code in script (after un-checking 'manually assign properties & attributes' alternative ):

$('#12345').click(function() { homecoming true ; });

but not working.

can please help me out this. badly stuck in this.

thanks, adi

if want rule trigger onclick of div id 12345 set div#12345 element tag/selector field (it accepts css path, evaluated queryselectorall).

if looking alternatively more "manual" way, i.e. want click event generic , 100% custom status w/ own logic, must come in value in element tag/selector field, because dtm needs know attach event to. @ minimum need top level, e.g. body. iow need same principle event delegation.

then in...

rule conditions -> info -> customs

..you can pretty much want, must homecoming true or false.

so example, had following:

$('#12345').click(function() { homecoming true ; });

this isn't going work expected, because attaching event handler. event based rule handles event, why have specify event, i.e. "click". code going end returning falsey value since aren't returning anything.

so instead, you'd this:

set element tag/selector div or top level body, in custom section, this:

if ( $(this).attr('id') == '12345' ) homecoming true; else homecoming false;

note utilize jquery syntax because used in post; dtm doesn't output jquery or have built-in, need ensure jquery loaded work. it's easy plenty "vanilla js" version of getting id attribute of this

if want able specify own event handler, had:

$('#12345').click(function() { homecoming true ; });

then best thing can instead output in page load rule in javascript / 3rd party script section. there you'd create closure phone call direct phone call rule instead of returning true, example:

$('#12345').click(function() { _satellite.track('dosomething'); });

then create direct phone call rule instead of event based rule, , string condition, you'd set "dosomething" , pop whatever want within there.

javascript jquery html adobe adobe-analytics

No comments:

Post a Comment