Google Analytics - Tracking Nonstandard Query Strings - google-analytics

I am trying to track query strings in Google Analytics, but I have a problem. I have too many variables to fit in the "normal set" provided by Google. They allow you to set utm_source, utm_medium, utm_term, utm_content and utm_campaign. I need another one, let's call it my_qs.
So my URL would look like:
http://example.com?utm_source=stack-exchange&utm_medium=web&utm_term=google-analytics&utm_content=nonstandard-query-strings&utm_campaign=answers&my_qs=gotmike
I can obviously find reports for all the standard query strings in Google Analytics, but I'm having a tough time figuring out how to run reports on these other variables that show up in the URLs.
I looked into Custom Variables, and they seem like something that is set by the Google Analytics code, not by the query string in the URL.
Maybe the answer is to write some javascript to grab my query string and store it as a Custom Variable in Google Analytics?
I read several articles about creating Custom Variables based on data stored on your website, but I'd really like to provide a simple URL link back to my website and get the data from the query string based on a user clicking that link.
Any ideas on how to accomplish this?

If you are using GTM, then you can grab the query parameter quite easily by creating your own variable to grab your qp. The variable would look something like this:
You could then provide "my_qs parameter" as a value for your Custom Dimension in your tags. Make sure you have already defined and configured this in your GA account first.

Related

Use look-up table in Tag Manager to determine which Analytics Property to post data to, based on URL

I have two websites on the same domain: example.com/fr and example.com/us. Each website has its own Google Analytics Property. I'd like to record page view data in each website's respective Analytics property.
Since there may be many more websites and Analytics Properties in future I thought the best way to manage this would be to create a custom variable of type RegEx Table to map Page URLs to Analytics Property Ids, like this:
*example\.com/us* maps to: UA-123456789-0
*example\.com/fr* maps to: UA-123456789-1
etc
…then use that variable as the value of the 'Google Analytics Settings' field in a new Universal Analytics Tag. I feel like I've set this up properly but it just will not log any data in Analytics whatsoever. I've tried it with even the loosest RegEx patterns e.g *example\.com* and even * and still nothing gets into Analytics.
I've tried a similar thing using a Lookup Table (as opposed to a RegEx Table) and that works as expected, but I believe a look-up table is limited to matching only an exact URL, so if I map http://example.com/us/ to UA-123456789-0 (my US site's Analytics Property Id) it works great when I visit that page exactly, but when I visit http://example.com/us/test/ it doesn't log anything as the URL isn't matched exactly in the lookup. So I know the principle of what I'm doing works with a Lookup Table, but it seems the same approach doesn't work with a RegEx Table.
I wanted to ask:
It is possible to use a Regex table for outputting an Analytics Property Id?
If so, any pointers as to what I might have done wrong?
If not, are there any other neat options? (Otherwise I'm potentially going to have to set up a lot more variables/events/tags if I need to log the same things on each site to different Analytics Properties - it'd involve adding the same conditions onto pretty much every tag.
Many thanks.
As prompted by the comment from #EikePierstorff, it seems that it is possible to use a Regex Table as a lookup for determining the Analytics Property Id to use based on URL. The simple issue was incorrect RegEx expressions.

How to analyze multiple query parameters in Google Analytics

I'm setting up Google Analytics for a website where a user can find an event to attend (concerts, plays, etc.). The results can be filtered by 5 different parameters.
So, unfiltered results would look like: example.com/event-finder/
And filtered results showing concerts in January or February would look like: example.com/event-finder?type=concert&month=jan,feb
I'm struggling to figure out the best way to use the query parameters in Google Analytics to analyze filtering behavior.
Example questions I'd want to be able to pull answers for:
What percentage of results were filtered by type?
What percentage of results were also sorted by month?
What is the most common type filtered by?
I have full access to both Google Analytics and Tag Manager but I suspect I shouldn't do this with events or custom dimensions and that there's got to be a way to use the query parameters to do this in a clean way.
I've tried to use a new view and site search to group the types of filters. Seems like it could work, but seems hacky and limited.
I've considered pushing those values into custom dimensions, but that too seems like overkill.
I've considered pulling content reports into Google Sheets and sorting through things there, but I'm 1) not entirely sure how I'd do that and 2) suspect there may be an easier approach.
Let me know if you have any questions or need more clarification. Thanks!
Have you tried to use "category parameters" when configuring site search (admin -> view settings)? You could set the "type" as a category parameter. You can also enter multiple parameters in there.
Check this screenshot of site search configuration

Using advanced filters - Google Analytics

A client I am working for has a requirement to use historical data in Google Analytics to present a report that shows them page views on a specific page, but only when refereed to said page from the homepage, basically like in-site ad tracking. I have discovered that I can create reports that are grouped on a user-defined variable, however I need previous data to also be included in this report, and therefore cannot simply define this inside of my Google Analytics call.
I have therefore been experimenting with Advanced filters, in an attempt to populated the user-defined field with a query-string variable. I have attached an image below illustrate my current configuration:
This configuration isn't populating the "User-Defined" field, and therefore not producing the desired results.
Any help would be appriciated.
Any filters you set will only be applied to new data, not historic.
Probably what you are after can be retrieved through the Analytics API (you can use the Query explorer for that).
Try the following:
dimensions: ga:nextPagePath
metrics: ga:uniquePageviews
filters: ga:previousPagePath=~<YOUR STARTING PAGE>;ga:nextPagePath=~page\=
sort: -ga:uniquePageviews
What the query is asking is "Which are the top pages that include 'page=' did users click on from your starting page?"

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.

Resources