Events twice in Request URL

Avatar

Avatar

ryanw79814830

Avatar

ryanw79814830

ryanw79814830

07-12-2018

What causes two event parameters to show up in the request string? I am sending additional s.t() page calls on a single page angular app and events are duplicating in the single request. Example in red:

pageName=%2Fhp%2Fscheduling%2Fmain.html%23%237&g=https%3A%2F%2Fwebuata.healthpartners.com%2Fhp%2Fscheduling%2Fmain.html%23%231&c.&events=event46&.c&server=webuata.healthpartners.com&events=event46&aamb=RKhpRz8krg2tLO6pguXWp5olkAcUniQYPHaMWWgdJ3xzPWQmdj0y&c4=%2Fhp%2Fscheduling

I am using s.clearvars on every angular location change before the events are set and s.t(). I also added some console logs to verify that the code that sets s.events is only run once per s.t(). I am loading this is a custom code launch rule. This is the simple version of the code. If the angular page has is a certain value, I went to send events, otherwise page call with no events.

        rs.$on("$locationChangeSuccess", function(){

            s.clearVars();

            s.pageName=document.location.pathname+document.location.hash;

            if ( document.location.hash.includes('4') ) {

               s.events="event46";

          }

          s.t();

     }

Thanks!

Ryan

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

AlexisCazes

MVP

Avatar

AlexisCazes

MVP

AlexisCazes
MVP

10-12-2018

Hi Ryan,

The Adobe Analytics library translates the variables of your analytics object and append them to the Adobe Analytics server call.

If you look closely you will notice that one of your events is between c. and .c which means you are settings s.events and a contextData variable events (the one between c. and .c). contextData variables will only be processed if you have created processing rules in Adobe Analytics interface to map them correctly.

You initial request as per above:

pageName=%2Fhp%2Fscheduling%2Fmain.html%23%237&g=https%3A%2F%2Fwebuata.healthpartners.com% 2Fhp%2Fscheduling%2Fmain.html%23%231&c.&events=event46&.c&server=webuata.healthpartners.com&events=event46&aamb=RKhpRz8krg2tLO6pguXWp5olkAcUniQYPHaMWWgdJ3xzPWQmdj0y&c4=%2Fhp%2Fscheduling

contextData variables &c.&events=event46&.c

Default events variables: &events=event46&

Context Data Variables

So you must have have something in your code like s.contextData['events'] = 'event46';

Answers (3)

Answers (3)

Avatar

Avatar

pabloc82923542

Avatar

pabloc82923542

pabloc82923542

10-12-2018

Hmm ok that makes it more difficult teh custom code part. I would recommend trying to add a console log to see if and where the 2nd event is triggered.  I recommend check any code or rules that may have secondary data rules attached/firing that may be causing the event to fire that second time.

GLTU

Avatar

Avatar

ryanw79814830

Avatar

ryanw79814830

ryanw79814830

07-12-2018

Issue is a little different. There is no double firing happening. There is one call, but the event parameter is included twice in the single call. This is causing our events to count twice. I am loading all the analytics code through launch but it's all custom code.

Avatar

Avatar

pabloc82923542

Avatar

pabloc82923542

pabloc82923542

07-12-2018

I am guessing a bit here so forgive me if I did not understand fully what teh issue is.

When using angular sometimes a template that has your analytics code in plus the fact you run second version in angular app startup causes a double fire on first start up of the app.

if that is the case then just create an exception rule for the first time load of the app.

Under "customize pagecode" in your DTM (I assume this is what you are using) open editor add line...

if (document.location.pathname == "/yourapp/path/"){

return false;

this should remove double firstime fire in angular apps.

l`m not sure what events you are trying to setup but for angular apps I really recommend you use direct call rules to setup tracking of page state changes(fake pageviews basically). Then use data layer populate your pagename variable. Then the odd custom event or s.tl can be injected as needed for post secondary page load things like custom link clicks... If you don't have it turned on get Activity map installed as well. It is amazing to automatically get advanced link and button tracking with no extra code lift for you.