Search code examples
node.jsgoogle-analyticsgoogle-cloud-functionsuniversal-analytics

Universal-Aanalytics: Visitor.event() call is failing with label values


I am using universal-analytics for Google Analytics, but the visitor.event() call with label value as a string is not working.

As per the below document, it says the label value should be non-negative, does it mean it only accepts Integers or String as well? https://github.com/peaksandpies/universal-analytics/blob/master/AcceptableParams.md

FYI:

visitor.event(category, action, label).send(); // Working and events are reported.

Example: {"category":"APISvc","action":"URLStats","label":"Called"}

visitor.event(category, action, label, labelValue).send(); // NOT Working.

Example: {"category":"APISvc","action":"URLStats","label":"Success","labelValue":"2S"}

Context: Using this in Cloud Functions (NodeJS) on Google Firebase.

Appreciating your help!


Solution

  • The value component, for a Google Analytics event, if it is defined it must be an integer (https://support.google.com/analytics/answer/1033068?hl=en).

    Example:

    {"category":"APISvc","action":"URLStats","label":"Success","labelValue":2}