Expand my Community achievements bar.

SOLVED

Try to track internal link on adobe launch

Avatar

Level 1

Hi,

I am trying to track the internal link of the below categories.

1650022_pastedImage_1.png

below is the html part:

1650032_pastedImage_3.png

I want the link names on every click. like:'Gallery', 'Codes' etc.

Created a data element with custom code:

1650040_pastedImage_12.png

below is the JavaScript code which is in the editor:

1650044_pastedImage_13.png

On Adobe launch, i Set this rule below:

1650038_pastedImage_8.png

I want to track the click on the categories, so select the 'click' event type and added the css selector part below:

1650033_pastedImage_4.png

Added a simple condition which will work easily:

1650034_pastedImage_7.png

Now in Action Configuration, i set the variables: evar4 Set as %Custom_catching_li_value%

1650047_pastedImage_14.png

But in launch assets request, v4 is not coming, c2 is coming null, events: event4

Can anyone help, How to fix this and make it better?

Please help to advise.

Thanks!

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

This looks pretty good with the exception of how you are using data elements.

There are a couple things worth noting:

1). There is no need to set up event listeners in code.  Launch does all that for you depending on the type of event that triggers your rule.

2). Data Elements are like functions that get called whenever they are referenced.  If the data element is Core > Custom code, that code is expected to return something.  In yours, you establish a listener that has a return, but it won't be fed back as the return value of the data element.  Also, there is a timing issue, since the data element is not evaluated until after the rule is triggered, which then sets up a listener that might get triggered upon the next click.

Anyway, while there are some legitimate reasons to set up event listeners in custom JS in Launch, those cases are pretty rare.

So...  What's the solution?

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

This looks pretty good with the exception of how you are using data elements.

There are a couple things worth noting:

1). There is no need to set up event listeners in code.  Launch does all that for you depending on the type of event that triggers your rule.

2). Data Elements are like functions that get called whenever they are referenced.  If the data element is Core > Custom code, that code is expected to return something.  In yours, you establish a listener that has a return, but it won't be fed back as the return value of the data element.  Also, there is a timing issue, since the data element is not evaluated until after the rule is triggered, which then sets up a listener that might get triggered upon the next click.

Anyway, while there are some legitimate reasons to set up event listeners in custom JS in Launch, those cases are pretty rare.

So...  What's the solution?

Avatar

Community Advisor

Did this help?  Did it solve your issue?  If so, please mark the answer as correct.  If not, let's pick the discussion back up.

-Stew