Felipe
Felipe

Reputation: 494

Send custom metric to google analytics

I've created a custom metric called loadtime: custom metric

Here is how I'm creating the session:

ga('create', analyticsCode,{ 'cookieDomain': 'test'});

I'm sending it to analytics like this:

var timeDiff = Math.round((Date.now() - initialTime) / 1000); ga('set', { 'loadtime': timeDfff }); ga('send', 'pageview');

I'm getting the pageview information, but when I try to create a report to check my custom metric, I see no information. I've been trying to send this information for the past 3 days, so the analytics delay can't be the problem.

What am I doing wrong here? It is a Single Page Application, so that's why I'm sending my own page load time.

Thanks

Upvotes: 0

Views: 220

Answers (1)

Joe Law
Joe Law

Reputation: 245

You shouldn't have the name of the metric in your code, only the number. Change your code to

var timeDiff = Math.round((Date.now() - initialTime) / 1000);
ga('set', { 'metric1': timeDfff });
ga('send', 'pageview');

It's confusing as Google's old documentation is still widely available.

Upvotes: 1

Related Questions