Anthony Raimondo
Anthony Raimondo

Reputation: 1721

Google Analytics Tracking Events With Dimensions Incorrect Relations

Im trying to track an event that has 3 dimensions (user id, widget id,post id). Every click event must have its own row with a unique post id, user id and widget id so i can track the number of clicks per post. Extra: All the dimensions are set to have a scope of 'user'.

ga('send', 'event', 'widget', 'click', 'uwp', 
                        {
                            'dimension1': $user_id,
                            'dimension2': $widget_id,
                            'dimension3': $post_id
                        }
                    );

I later query using the reporting api.

$result = Analytics::query(
                $start_date,
                $end_date,
                'ga:totalEvents',
                array(
                    'dimensions' => 'ga:dimension3,ga:pagePath,ga:date,ga:eventAction',
                    'sort'       => '-ga:date',
                    'filters'    => 'ga:eventAction==click;ga:eventLabel==uwp;ga:dimension1=='.$user->id,
                    'max-results'=> '100'
                ));

The result is incorrect all the clicks are being bundled up into 1 dimension, being dimension3 the post id. Ex) If i click on a post of id 30 (dimension3 is set to 30) and a post of id 10 it will report that post of id 30 has 2 clicks or some older id has 2 clicks.

Google Analytics Dashbaord Picks: enter image description hereenter image description here

As you can see from the pick i have 1 row with post id of 2 and 7 clicks, yet i sent events with many different post ids. (dimension3 == post id).

Upvotes: 3

Views: 341

Answers (1)

Andy
Andy

Reputation: 196

The problem here is that you are setting all of these dimensions to have a scope of user. Because of this, each dimension can only have one value per user. This is fine for the user id dimension, but for a dimension like post id, this is likely incorrect. Presumably, a user can view many post ids. Setting post id to user scope will cause the post id value to be overwritten with the latest post each time a new post is seen (which is why only one value is appearing in your report). You'll instead want to set post id to have a scope of hit, which will allow a different value to be sent on each event hit.

You can change the scope via the interface.

Read more about custom dimension scope.

Upvotes: 2

Related Questions