Google Analytics segmentation customvar vs uri - google-analytics

I want to be able segment analytics data by company once my customers have logged into my website. Being very new to analytics, it seems like there is a couple of ways I could do this.
Set a visitor level custom variable that would signify the company. For instance, _setCustomVar(1, 'customer', 'ABC Corp', 1)
Pass in a custom Url to my _trackPageview calls whose first segment would signify the company. For instance, _trackPageview('/ABCCorp/the rest of the document path, querystring, etc.')
It seems you can't filter on a custom variable so I could not create a view\profile for each company but I could use Segments and Custom Reports off an 'All Web Site Data' view to do that instead.
Going the custom url route seems to be more flexible since I could either filter or use segments.
Are there any other pitfalls or reasons to suggest using one of these two approaches over the other?

This use case is better suited for custom variables.
Changing the URL will make it more difficult to do things like "How many home page views did I get" or "What do clients usually do after they login".
Also, you can create custom reports based on the information you're passing back and include the custom variable information as the first key. Pretty easy to duplicate GA's current top reports in a custom report using the custom variable as the main dimension.

Agree with Tom that CustomVar is a much better and cleaner solution.
You might want to switch to new Universal Analytics and use Custom Dimenions instead. It's even better and you can set up property filters with Custom Dimenions too, so this should cover all your needs.

Related

What is the proper way to tag pages in Google Analytics?

I don't even know if "tagging pages" is what I mean.
Essentially, I have a large education website with many types of pages. Specifically, I want to tag our program pages by faculty, level, etc. For example, the Biology program page would be tagged with Science (as its faculty), and Undergraduate (as its level). It's possible that a program could belong to multiple faculties and/or levels (Psychology, for instance, is both a Science program and an Arts program). There is nothing in the URL to signify faculty or level. The website is built in Drupal, in case you know of any modules that could facilitate this.
I want to understand how different faculties/levels/etc perform. I will be building reports in Google Data Studio.
Any guidance would be appreciated!
What you are looking for is called 'content grouping'. If you haven't information in the URL you can define some rules when the page loads and pass the information to Analytics with the pageviews.
You can find more information here:
https://support.google.com/analytics/answer/2853423?hl=en
Then you can get these information from Data Studio.
Because of your multi-value needs, nothing in GA is going to satisfy your requirements out of the box. You will have to do some post-processing, and I am not familiar enough with Data Studio to know where its limits are in that regard.
As the previous poster suggested, Content Grouping is the standard way to create custom aggregations of pages. You can have multiple content groupings, such as Faculty and Level, but a page can be in only one group per grouping (not the clearest terminology but it appears to be what Google uses).
A different option is Custom Dimensions. There are two options here. One is to create custom dimensions for Level and Faculty. Each page can still have only one value per dimension, but you could send a comma-delimited string when a department is in multiple faculties (for instance) and then pull it apart again in a spreadsheet.
The second option is to create a custom dimension for Department directly, and associate each department to the appropriate one or more faculties and levels in your reporting.
How you set the custom dimensions or content grouping will depend on your implementation of GA. If you are using the Google Analytics Drupal module, it says it supports setting custom dimensions as a feature. If you are using Google Tag Manager you can set the dimension value in your tags directly, though of course it will need to decide what value to set on based on either totally enumerated rules you write or something it can read out of the page. Here is some Tag Manager documentation: Content Grouping via GTM; Custom Dimensions via GTM.
If the department is present in the page in some consistently marked-up way you can grab it; if not the Metatag module or one of its schema.org extensions might be able to provide you a spot to set a value for GTM to retrieve.

can google analytics tell me http referrer for each specific goal conversion?

I have a website that allows people to create an account (that is the conversion I wish to track).
I wish to know where a specific person is coming from. I have google analytics installed and have set up the registration page as a goal, but the reporting tells me traffic sources as an aggregated pie chart. It doesn't report down to the user account level to say that 'person with email xyz' came from 'facebook' for example.
What custom variables or mark up would I need to add to GA to report at that detailed level, if that is at all possible?
Otherwise, I will just have to record the first http_referer in a cookie and stick it in a database during the registration process.
Any advice?
Firstly I must ask you, how actionable do you think it is to look at data at that granular of a level? Finding out what % of people who registered came from facebook or some other place is actionable, because it helps you do things like determine where to focus marketing efforts. But individual users? How is this actionable to you? (hint: it's not)
However, if you are still determined to know this, you should first note that it is against Google's ToS to record personally identifiable data both directly (recording the actual value in GA) or indirectly (e.g. - recording a unique id that you can use to tie to personal info stored within your own system). If this is something you don't want to risk, I suggest moving to another analytics tool that does not have this sort of thing in their ToS (e.g. Adobe SiteCatalyst, which costs money, or perhaps you may instead prefer to choose an "in-house" approach, like Piwik)
If you are still determined to follow through with this and hope not to get caught or whatever, Google Analytics doesn't record data like what info a visitor filled out in a form (like their email address) unless you populate that data in a custom field/dimension/metric/event to be sent along with the request. Usually you would populate this on the form "thank you" page (which is usually the same page you use as your goal url or goal event if you're popping and using an event for your goal). So you would populate the email address in one of those custom variables and then have it as a dimension to break down the http referrer by.

Google Analytics Custom Variable/Value Report (How?)

I was able to setup Google Analytics to send custom variables that I can track.
I'd like to generate a report with UserId / Value and Display all of the pages
that user viewed. (Similar to reports I have seen with IP address on one column,
and viewed pages on the other)
Custom Var 1 : label:'userId' value:'17' scope:'1' (from Chrome Analytics tool)
Google Analytics reporting is pretty complex, so I'm hoping I can get some suggestions on how to create such a report.
i'm battling through google analytics aswell it can be really useful but to get exactly what you want can take some time. This isn't an answer as much as its a list of a few links that i have used along the way and hope they help
http://ga-dev-tools.appspot.com/explorer/
In here if you put ga:source ga:referralPath ga:customVarName(n)
This stack overflow answer may also help
Create google analytics profile by filtering using a custom variable
i'll have to look into this myself when i m using custom variables but it look like the advanced segment section may be the way to go.
And you ve probably already seen this but its quite a nice article on custom variables
https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables
Let us know hwo you get on...
I think you're going to want to create an advanced segment including your custom variable. This should narrow the data to only that which includes the variable. You can then look at whatever reports you want within that segment.
Using regular expressions should let you better tune the scope of the segment.
You can do this easily in the Megalytic reporting tool. There are widgets that let you create reports which segment data by custom variable. For example, Traffic by Custom Variable, Conversions by Custom Variable. Disclaimer: I am a founder of Megalytic.

Is it possible to change URL structure and to continue to gather Analytics data to the existing posts?

I am changing my WordPress permalinks from:
/%category%/%post_id%/
to:
/%postname%/
Is it possible to make Google Analytics to continue gathering the post's data correspondingly?
Unfortunately, there is no way to have GA remap previous page name values to new page name values, so you will not be able to compare historical data to current data within GA. To do that, you will have to do a query on your wordpress data to make your own lookup table, etc..
One thing you can do is have GA continue to populate with the old URL...the _trackPageview call takes an optional argument to specify the page name you want reported. You will have to write some server-side code to expose the old value to GA though. Or maybe it might be exposed in a variable already and you just have to pass it to GA.
Another thing you can do is kind of a hybrid.. let GA start recording the new URL as the page name, but also populate one of GA's custom variables with the old URL. You would have to expose it like above, but then it will tie the two values together within GA. There would still be some manual work to do in GA to do things like compare historical data to new data but it might be easier for you to go this route.
You needn't worry about that. It will handle the permalink change automatically and collect the stats as usual.

Advice needed on REST URL to be given to 3rd parties to access my site

Important: This question isn't actually really an ASP.NET question. Anyone who knows anything about URLS can answer it. I just happen to be using ASP.NET routing so included that detail.
In a nutshell my question is :
"What URL format should I design that i can give to external parties to get to a specific place on my site that will be future proof. [I'm new to creating these 'REST' URLs]."
I need an ASP.NET routing URL that will be given to a third party for tracking marketing campaigns. It is essentially a 'gateway' URL that redirects the user to a specific page on our site which may be the homepage, a special contest or a particular product.
In addition to trying to capture the referrer I will need to receive a partnerId, a campaign number and possibly other parameters. I want to provide a route to do this BUT I want to get it right first time because obviously I cant easily change it once its being used externally.
How does something like this look?
routes.MapRoute(
"3rd-party-campaign-route",
"campaign/{destination}/{partnerid}/{campaignid}/{custom}",
new
{
controller = "Campaign",
action = "Redirect",
custom = (string)null // optional so we need to set it null
}
);
campaign : possibly don't want the word 'campaign' in the actual link -- since users will see it in the URL bar. i might change this to just something cryptic like 'c'.
destination : dictates which page on our site the link will take the user to. For instance PR to direct the user to products page.
partnerid : the ID for the company that we've assigned - such as SO for Stack overflow.
campaignid : campaign id such as 123 - unique to each partner. I have realized that I think I'd prefer for the 3rd party company to be able to manage the campaign ids themselves rather than us providing a website to 'create a campaign'. I'm not
completely sure about this yet though.
custom : custom data (optional). i can add further custom data parameters without breaking existing URLS
Note: the reason i have 'destination' is because the campaign ID is decided upon by the client so they need to also tell us where the destination of that campaign is. Alternatively they could 'register' a campaign with us. This may be a better solution to avoid people putting in random campaign IDs but I'm not overly concerned about that and i think this system gives more flexibility.
In addition we want to know perhaps which image they used to link to us (so we can track which banner works the best). I THINK this is a candiate for a new campaignid as opposed to a custom data field but i'm not sure.
Currently I am using a very primitive URL such as http://example.com?cid=123. In this case the campaign ID needs to be issued to the third party and it just isn't a very flexible system. I want to move immediately to a new system for new clients.
Any thoughts on future proofing this system? What may I have missed? I know i can always add new formats but I want to use this format as much as possible if that is a good idea.
This URL:
"campaign/{destination}/{partnerid}/{campaignid}/{custom}",
...doesn't look like a resource to me, it looks like a remote method call. There is a lot of business logic here which is likely to change in the future. Also, it's complicated. My gut instinct when designing URLs is that simpler is generally better. This goes double when you are handing the URL to an external partner.
Uniform Resource Locators are supposed to specify, well, resources. The destination is certainly a resource (but more on this in a moment), and I think you could consider the campaign a resource. The partner is not a resource you serve. Custom is certainly not a resource, as it's entirely undefined.
I hear what you're saying about not wanting to have to tell the partners to "create a campaign," but consider that you're likely to eventually have to go down this road anyway. As soon as the campaign has any properties other than the partner identifier, you pretty much have to do this.
So my first to conclusions are that you should probably get rid of the partner ID, and derive it from the campaign. Get rid of custom, too, and use query string parameters instead, should it be necessary. It is appropriate to use query string parameters to specify how to return a resource (as opposed to the identity of the resource).
Removing those yields:
"campaign/{destination}/{campaignid}",
OK, that's simpler, but it still doesn't look right. What's destination doing in between campaign and campaign ID? One approach would be to rearrange things:
"campaign/{campaignid}/{destination}",
Another would be to use Astoria-style indexing:
"campaign({campaignid})/{destination}",
For some reason, this looks odd to a lot of people, but it's entirely legal. Feel free to use other legal characters to separate campaign from the ID; the point here is that a / is not the only choice, and may not be the appropriate choice.
However...
One question we haven't covered yet is what should happen if/when the user submits a valid destination, but an invalid campaign or partner ID. If the correct response is that the user should see an error, then all of the above is still valid. If, on the other hand, the correct response is that the user should be silently taken to the destination page anyway, then the campaign ID is really a query string parameter, not a part of the resource. Perhaps some partners wouldn't like being given a URL with a question mark in it, but from a purely REST point of view, I think that's the right approach, if the campaign ID's validity does not determine where the user ends up. In this case, the URL would be:
"campaign/{destination}",
...and you would add a query string parameter with the campaign ID.
I realize that I haven't given you a definite answer to your question. The trouble is that most of this rests on business considerations which you are probably aware of, but I'm certainly not. So I'm more trying to cover the philosophy of a REST-ful URL, rather than attempting to explain your business to you. :)
I think the URL rewriting is getting out of hand a little bit lately. Not everything belongs to the URL. After all, a URL is supposed to describe a resource that can be searched for, discovered or manipulated and it seems to me that at least the partner ID and the custom fields from above are not part of the resource.
Not to mention that that at some point you would like to actually keep the partner ID constant across multiple campaigns and that means that it is now orthogonal to the particular places they need to visit. If you keep these as parameters, you will allow your partners to access uniformly multiple resources on your website, while still reliably identifying themselves, so you can track their participation in any of your campaigns.
It looks like you've covered all of your bases. The only suggestion I have is to change
{custom}
to
{*custom}
That way, if you ever need to accept further parameters, you don't have to take the chance that old URLs will get a 404. For example:
If you have a URL that looks like:
campaign/PR/SO/123
and you decide in the future that you would like to accept a fourth and fifth parameter:
campaign/PR/SO/123/blah/foo
then the first URL will still be valid, because you're using a wildcard character in {*custom}. "blah/foo" would be passed as a string to your action. To get those extra two parameters, you would simply split the custom argument in your action by '/'. Add some friendly error handling if they don't exist and you've successfully changed the amount of information you can receive with a campaign URL without completely breaking URLs already in the wild.
Why not use URL encoded variables instead of routes? They're a lot more flexible - you can add any new features in the future while still maintaining 100% backwards compatibility. Admittedly, it's a little more trouble to type manually, but if there's all those parameters anyway, it's already no picnic.
http://mysite.com/page?campaign=1&dest=products&pid=15&cid=25
To me, this is much more indicative of what is really going on. Using paths implies a that a resource exists at that location. But really you're just providing a web service with various parameters, and this model captures that much more clearly. And in the future, you can add more parameters effortlessly. You can also default parameters if they are missing without messing anything up.
Not sure of the code in ASP, but it should be trivial to implement.
I think I'd look at doing it the way that SO does it's questions.
"campaign/{campaign-id}/friendly-name-of-campaign"
Create a mapping in your database when the campaign is created that associates all the data you need with an automatically generated id. The friendly name could be assigned basically the same way as a question is on SO -- by the user -- but you could also have an approval process that makes sure that it meets your requirements and is distinct from any existing campaign names. Your tracking company can track by the id and you can correlate that with your associated data with a simple look up.
What you have looks good for your needs. The other posts here have good points. But may not be suitable for you. One thing that you could consider with future proofing your links is to put a version number somewhere in there.
"campaign/{version}/{destination}/{partnerid}/{campaignid}/{custom}"
This way if you decide to completely change your format you can up the version to 2.0 (or whatever) and still keep track of the old links coming in.
I would do
/c/{destination}/{partnerid}/{campaignid}/?customvar=s
You should think about the hierarchy of the first parameters, you already got that managed quite well. Only if there's a hierarchy path segments should be used.
From your description, destination seems to be the broadest parameter, partnerid only works with destination, and campaingid is specific to a partner.
When you really need to add custom parameters I would go for query variables (they are not forbidden in REST), because these are not part of the hierarchy.
You also shouldn't try to be too RESTful here. After all, it's for a campaign and for redirecting to a final resource. So the URL you want to design here is not really a specific resource in the terms of REST.
Create an URL called http://mysite.com/gateway
Return an HTML form, tell your partners to fill in the form and POST it. Redirect based on the form values.
You could easily provide your partners with the javascript to do the GET and POST. Should be trivial.
The most important thing i have learned about REST URLĀ“s thats usually burried deep in some book or article:
The URL should point to a resource and the following ?querystring should have all the scoping information needed. DONT mix those two or you will have a design thats very hard to work with.
Other then that i fully agree with Craig Stuntz

Resources