Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

DTM keypress question

c_a11
Level 2
Level 2

Hi people, new to DTM.

I am trying to setup a keypress condition which only fires if keyCode is X. How do I setup the rule properly for the keyCode check?

1 Accepted Solution
c_a11
Correct answer by
Level 2
Level 2

Alright, I managed to "hack" it up so it works.

Summary of issues:

1) Expose KeyDown as rule condition

2) In the script, when defining the condition function, DTM should pass the same variable that is passed through to the ruleMatch function.

ie. 

            var h = b.find(o, function(e) {
                try {
                    return !e.call(i, n, u)...

e is the condition function which is called with 3 variables. But on init, the condition is only declared as a simple function()

            conditions: [function() {

It should take in 3 variables too so that custom rule condition can make use of the 3 variables for customized tracking.

The below is what I used in the pageload rule to run a custom "hack" for my rule. My event rule is I want to track left arrow key press when a pop up is in the dom (media gallery scenario)

_satellite.registerEvents($("body")[0], ["keydown"])

_satellite.rules[0].conditions[0] = function(i, n, u){console.log(i); return $("popup").length>0&&37===i.keyCode;};

_satellite.rules[0].event = "keydown"

View solution in original post

4 Replies
shekhardhiman
Employee
Employee

Hi There,

Thanks for reaching out to Adobe Community.

Please see if the below article helps:

http://microsite.omniture.com/t2/help/en_US/dtm/t_rules_event_conditions.html

Thanks!

c_a11
Level 2
Level 2

Nope, it doesn't help. I basically want to use DTM to track if the user presses a particular key. 

c_a11
Level 2
Level 2

I also need the KeyDown instead of KeyPress as keypress doesn't capture all the key presses.

c_a11
Correct answer by
Level 2
Level 2

Alright, I managed to "hack" it up so it works.

Summary of issues:

1) Expose KeyDown as rule condition

2) In the script, when defining the condition function, DTM should pass the same variable that is passed through to the ruleMatch function.

ie. 

            var h = b.find(o, function(e) {
                try {
                    return !e.call(i, n, u)...

e is the condition function which is called with 3 variables. But on init, the condition is only declared as a simple function()

            conditions: [function() {

It should take in 3 variables too so that custom rule condition can make use of the 3 variables for customized tracking.

The below is what I used in the pageload rule to run a custom "hack" for my rule. My event rule is I want to track left arrow key press when a pop up is in the dom (media gallery scenario)

_satellite.registerEvents($("body")[0], ["keydown"])

_satellite.rules[0].conditions[0] = function(i, n, u){console.log(i); return $("popup").length>0&&37===i.keyCode;};

_satellite.rules[0].event = "keydown"

View solution in original post