Expand my Community achievements bar.

Help shape the future of AI assistance by participating in this quick card sorting activity. Your input will help create a more effective system that better serves your needs and those of your colleagues.
SOLVED

repeating events on direct call after DTM to Launch Migration

Avatar

Level 1

Hi there,

We have migrated DTM to Launch and testing it. while I am testing the site, I see repeating event string appended to the events variable.

I have main page load event. that set to add event1, event42.

when user scroll down the content, I am calling a direct rule that add additional events (event1, event41, event51, event42). But this direct rule will be triggered again and again when user scroll through the page. It was working fine as expected in DTM. But after migration, when direct rules are called, it is appending events to each calls.

ex:

1st call (pageload): event1,event42

1st direct rule: event1,event42,event1,event41,event51,event42

2nd direct rule: event1,event42,event1,event41,event51,event42,event1,event41,event51,event42

and so on.

How can I eliminating this?

1 Accepted Solution

Avatar

Correct answer by
Level 9

First of all: Do your rules have a Clear Variables Action (this is needed in Launch compared to DTM)?

Second: if yes, what version of the Analytics Extension are you using. There seems to be a bug in AppMeasurement.js 2.11.0 which is part of the Extension since 1.6.0 that sometimes doesn't clear events even when using Clear Variables action: What are possible reasons why ClearVariable fails?

If you don't want to clear your variables between these calls, you may have to add custom logic, with code. I am using a simple helper method where the first parameter is s.events and the second a string containing one or more events separated by a comma:

function concatenate(orig, addition) {

   if (typeof orig === 'string' && orig !== '') {

   var concat = orig + ',' + addition;

   var values = concat.split(',');

   return values.filter(function(value, index, self) {

   return self.indexOf(value) === index;

  }).join(',');

  } else {

   return addition;

  }

}

The filter method makes sure that each event is only present once.

View solution in original post

3 Replies

Avatar

Correct answer by
Level 9

First of all: Do your rules have a Clear Variables Action (this is needed in Launch compared to DTM)?

Second: if yes, what version of the Analytics Extension are you using. There seems to be a bug in AppMeasurement.js 2.11.0 which is part of the Extension since 1.6.0 that sometimes doesn't clear events even when using Clear Variables action: What are possible reasons why ClearVariable fails?

If you don't want to clear your variables between these calls, you may have to add custom logic, with code. I am using a simple helper method where the first parameter is s.events and the second a string containing one or more events separated by a comma:

function concatenate(orig, addition) {

   if (typeof orig === 'string' && orig !== '') {

   var concat = orig + ',' + addition;

   var values = concat.split(',');

   return values.filter(function(value, index, self) {

   return self.indexOf(value) === index;

  }).join(',');

  } else {

   return addition;

  }

}

The filter method makes sure that each event is only present once.

Avatar

Level 1

Hi,

I tried your suggested method already but I am facing a issue of clear other variables to like global evar values this i don't want to be clear.Please suggest best practice to overcome this issue.

Avatar

Level 1

thanks thomas.amsler

I figured it out. it was missing Clear Variables Action. your answer will help on this forum.