0

I'm trying to add custom data to my Google Analytics in a wordpress application I'm working on. I've got courses for a bunch of different colleges, and whenever the user interacts with one, I want to send a pageview with which college that course is at.

Here's how I'm sending it in javascript:

    ga('set','metric1',<?php echo $college->ID;?>);
    ga('send', 'pageview');

In the admin side of my analytics site, I have the custom metric scoped to Hit. here's what that looks like: imgur.

Whenever I navigate to a page with that code (it's in a template) while recording with Tag Assistant, you can see that the custom metric is being sent correctly.

However, on the analytics side, I tried to create a table to show pageviews per page where college = 4 (the ID of the specific college I'm testing) but it's not working.

In fact, if I go to the All Pages report, the page I'm trying to test doesn't even show up.

Where am I going wrong?

Alex Kibler
  • 4,674
  • 9
  • 44
  • 74

2 Answers2

1

It looks to me like you're using a custom metric when you should be using a custom dimension. Since you aren't really "counting" the college ID (if two people viewed college ID #4, your reports will show 8 so it could get confusing. The number could be in the thousands, too.

Try making a custom dimension instead and scope it appropriately. Then, when you view the Behavior > All Pages report you'll be able to add a Secondary Dimension (from the dropdown) and you can view the data right there (without needing to segment- but you can do that too).

Keep in mind when you segment the scope really comes into play- if you scope the dimension to "session" you can see all the hits (pages, events) that the user triggered associated to their college ID. You could scope it to the user too if you wanted to treat any session they have as attributed to that college ID.

Hope that helps!

GreatBlakes
  • 3,971
  • 4
  • 20
  • 28
  • That's very helpful. Thanks so much! I've actually been setting a custom metric and dimension at the same time, hoping that one of them would be right. I still can't make any reports around them though, so hopefully it'll be available tomorrow and then I'll mark this accepted – Alex Kibler Jun 27 '17 at 18:31
  • Yeah, the other thing you're running into is the data processing latency since custom definitions are not available in real-time, but I bet they'll appear after a few hours. – GreatBlakes Jun 27 '17 at 18:47
  • This is definitely what I needed to hear. I checked this morning and the custom dimension was showing up and everything was working perfectly! Thanks so much! – Alex Kibler Jun 28 '17 at 14:39
0

but before the code, that you posted. Have you added this line of code?

ga('create', 'YOUR_GA_ID', 'auto');
Killuminati
  • 261
  • 2
  • 11
  • Oh yes, I do. I didn't show it because I didn't want to give away my GA_ID but I guess I could've hidden it like you did – Alex Kibler Jun 27 '17 at 17:23
  • I'm suggesting this. Install the plugin and take a look what you are passing to GA. https://chrome.google.com/webstore/detail/google-analytics-debugger/jnkmfdileelhofjcijamephohjechhna?hl=en – Killuminati Jun 27 '17 at 17:26
  • also it could be, that for these custom params you need to create a report and you are doing in it a wrong way or you are not doing it at all – Killuminati Jun 27 '17 at 17:29
  • I installed Google's official analytics debugger and it showed that the custom params were being sent up just fine. And it's possible that I'm doing something wrong with my report. If you check this image, you'll see what I'm trying to do with the report: https://imgur.com/8a336zo – Alex Kibler Jun 27 '17 at 17:30
  • it looks ok, really. – Killuminati Jun 27 '17 at 17:40