Setting custom dimension value for a custom event

Hi @Kuba,

I follow this method and set up this tag :

_paq.push(["trackEvent", {{Category}}, {{Action}}, {{Label}}, 
     {
       dimension2: {{dimension2}},
       dimension3: {{dimension3}},
       dimension4: {{dimension4}},
       dimension5: {{dimension5}},
       dimension6: {{dimension6}}
     }
     ]);

However, no values appears in my hit. Then I tried to put this code in my configuration tag or/and in my event tag and the dimensions appears in my hit but they are empty.

_paq.push(['setCustomDimension', 2, {{dimension2}})
_paq.push(['setCustomDimension', 3, {{dimension3}})
_paq.push(['setCustomDimension', 4, {{dimension4}})
_paq.push(['setCustomDimension', 5, {{dimension5}})
_paq.push(['setCustomDimension', 6, {{dimension6}})

So I wanted to know where do I have to put each part of the code, in my configuration tag ? in my event tag ? Do I have to put both ?

Thanks for your help

Hi,

there are maybe several problems that prevent the data from showing up in reports: First of all, your _paq.push([“trackEvent”…) call misses an eventValue. Add a 0 of no value is present and try:

_paq.push(["trackEvent", {{Category}}, {{Action}}, {{Label}}, 0, 
     {
       dimension2: {{dimension2}},
       dimension3: {{dimension3}},
       dimension4: {{dimension4}},
       dimension5: {{dimension5}},
       dimension6: {{dimension6}}
     }
     ]);

If it still fails: did you make sure (in preview for example) that the {{dimensionX}} variables and others like {{Category}} and {{Action}} really contain values? You could try constant values instead of variables, too. Instead of implementing the changes, you can send the pushes in your browser´s console for faster feedback.

The Tracker Debugger should then help when you send broken events (they will show up there, along with an error message that indicates what is missing).

If they arrive there, you can inspect the raw data (hover over the “Custom Event” to get a link to the raw request). You should find your parameters and dimensions there if everything is okay:

image

EDIT: Your second attempt to set the dimension values before sending an event fails because of a missing “]” at the end. If you fix that and then send the event without dimension parameters, the result will match the first option to send them along with the event.

best,
Markus

1 Like

To confirm what Markus said, that would be the message shown in the tracker debugger:

Hi all,

Thank you very much for your help ! In fact, I when I put a 0 value it works !

Concerning the place to put the code :

_paq.push(['setCustomDimension', 2, {{dimension2}})

I can put it where I want before the event tag ?

Yes. Just make sure that it has been set before executing trackEvent. Also make sure to fix the typo Markus mentioned.

Note: it’s a deprecated method. I’d recommend using setCustomDimensionValue instead. Docs available here.

1 Like