0
votes

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?

2

2 Answers

1
votes

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!

0
votes

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

ga('create', 'YOUR_GA_ID', 'auto');