Expand my Community achievements bar.

Join us for an upcoming in-person Adobe Target Skill Builders event ~~> We're hosting these live learning opportunities to equip you with the knowledge and skills to leverage Target successfully. Learn more to see if we'll be coming to a city near you!
SOLVED

Tracking button clicks using alloy.sendEvent not increasing conversions

Avatar

Level 2

Hi All,

I have setup a custom code in one of the activities to fire a custom mbox and I am trying to track that in the conversion settings as viewed an mbox and selecting the parameters passed in audience refinement and checking the value. But it does not increase any conversions for the clicks happening , but If i try by clicked an element and set that as a metric the conversion does happen.

the custom architecture 

<script>

var btn = document.querySelector('button.efe-cta-primary');
  btn.addEventListener('click', function(){
  try{
  alloy("sendEvent", {
  renderDecisions: false,
  data: {__adobe: {target: {"clicked": "getStarted"}}},
  decisionScopes: ["click-mbox"]
  });
  }catch(err){
   //console.log("Error",err);
  }
  })
  </script>
and this is the settings in the conversions 
tarun_jamana8469_0-1671608559330.pngtarun_jamana8469_1-1671608590922.png

and I also see the interact call firing and the data being sent as payload in the network tab 

tarun_jamana8469_2-1671608760271.png

can anyone help me with why the conversions are not incrementing. Thanks in Advance

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

What else I notice about the script. I don't know when exactly it is executed. But what can also be possible is that the script executes right at the page load via target - but at this time the button does not yet exist in the DOM.

View solution in original post

3 Replies

Avatar

Community Advisor

Hi @tarun_jamana8469,

How is the HTML markup structured? Does the button have an href attribute? Maybe this is already the problem from the timing point of view.

Avatar

Level 2

Actually it is a button inside a form which has an onclick event on it which has some function which which gathers all the fields from it and then takes some time to redirect to the other page

Avatar

Correct answer by
Community Advisor

What else I notice about the script. I don't know when exactly it is executed. But what can also be possible is that the script executes right at the page load via target - but at this time the button does not yet exist in the DOM.