Expand my Community achievements bar.

SOLVED

DTM Populating custom event with an incrementor

Avatar

Level 3

Using DTM event based rules, I'm trying to set a number to an event, and would like Sitecatalyst to increment that custom event by said value.

It is a form based event (submit), but I am not receiving any data in SC. Code in the "Adobe Analytics" portion of the rule is as follows:

s.events="event35="+len; s.linkTrackVars="events"; s.linkTrackEvents="event35";

where 'len' is a number to increment by.

I have another counter event associated with this which simply increments by 1, and that performs only when this event35 is not defined in DTM.

Any help would be greatly appreciated!

1 Accepted Solution

Avatar

Correct answer by
Level 2

Hi Matthew,

The AppMeasurement is sort of made available directly in the Custom Page Code Editor for Adobe SiteCatalyst.  All the code that you put in the editor will be run in a function by DTM and the "s" object is being pass as an argument.

 

This pattern has worked for me,

// Get AppMeasurement from the arguments passed by the callee var s = arguments[1] || null; // Add my custom events if ( s ) { s.events += ",event32"; }

 

Here is the screenshot

[img]dtm-custom.png[/img]

View solution in original post

6 Replies

Avatar

Level 2

Hi Matthew,

Sometimes on form submit the timing for firing server calls to analytics is really tight. As a workaround, you could fire the event35 on the subsequent page view as long as your value was still accessible to you.

Also, sometimes when you don't see events firing when you code them in additional code section you just need to bind them to the window or document.

in this case it would be something like 

var s = window.s;

s.events="event35="+len;

s.linkTrackVars="events";

s.linkTrackEvents="event35";

Hope that helps,

Michael

Avatar

Level 1

s.events should be of the format: "event1,event2,...". There is no need to increment the counter yourself, events keep a counter automatically. So I would just write:

s.events="event35"

for the first line. Please let me know if that helps the issue.

Avatar

Level 3

Thanks for the responses.

Michael - I had tried this method, but for some reason I would get an "s is not defined" object error.

Toby - What I am trying to do is increment not just by one, but by a given value (could be 2, 5, 10, etc.)

As a workaround, I ended up just putting the standard SiteCatalyst code directly on the page, and that is working using the same code I have above. I will continue to troubleshoot the issue in DTM and report back with any more findings.

Avatar

Correct answer by
Level 2

Hi Matthew,

The AppMeasurement is sort of made available directly in the Custom Page Code Editor for Adobe SiteCatalyst.  All the code that you put in the editor will be run in a function by DTM and the "s" object is being pass as an argument.

 

This pattern has worked for me,

// Get AppMeasurement from the arguments passed by the callee var s = arguments[1] || null; // Add my custom events if ( s ) { s.events += ",event32"; }

 

Here is the screenshot

[img]dtm-custom.png[/img]

Avatar

Level 3

@andrewGats thanks so much for this pattern. I feel this is not very well documented and this totally solved my issues.

Avatar

Level 2

No problem.  I found this during my evaluation of the custom code feature.  I was able to find it pretty easily because the staging version of satellite code is pretty human readable.