I'm trying to track pageviews on certain types of pages across multiple websites with different url structures (which rules out using a RegEx to segment a common section of the URLs). Is it possible to track page loads with an event script? Would it be used as an onLoad event?
You CAN utilize regex to accomplish this, though it does depend on how many rules you have.
Example if you want to include these two urls:
www.google.com/inventory/example
www.microsoft.com/vehicle/example2
you can use
.*(\/inventory\/|\/vehicle\/).*
Another option is to use Google Data Studio and create a calculated field based on the "page" dimension and filter/group using CASE function.
Related
I have a multilanguage site and my plan is to track every language apart.
Example:
domain.com
domain.com/en/
domain.com/de/
domain.com/fr/
For now, I have one GA Property and one GTM Container for the whole site. I was thinking of creating multiple Properties in GA for every language and one for all together. So that would look like this:
domain.com -> GA-1
domain.com/en/ -> GA2
domain.com/de/ -> GA3
domain.com/fr/ -> GA4
Now in GTM I would add to the container one Tag for each Property and create a trigger for each property. GA-1 trigger fires on all pages, GA-2 trigger fires on some page views that page path contains /en/, GA-3 trigger fires on some page views that page path contains /de/...
Is this the best practice and would this work like this? or is there another method to achieve this goal? Or is it enough to create some Views in GA and create some filters for each language?
The goal is to track every language in a different property so the starting point is always the language. Maybe there are also different conversions in the properties.
In this situation, the best practice is to only have a single GA property that tracks the whole site. If you then want to only report on the data from a specific section of your site (i.e. a specific language) then you would use GA views (and filters) to achieve this. You would filter based on the Page dimension (e.g. Page starts with /fr).
There is no benefit to creating a property for each language except maybe to prevent you from going above the 10 million hits per property per month limit of the free version of GA. On the other hand, there is a benefit to tracking the entire site in a single property. The main benefit is that it allows you to perform cross-language analysis.
I would like to add another solution to your question, where you can actually get the result you're asking for (even though it's not best practice).
If you go to Variables > User-Defined Variables -> New
Let's give the variable a name like UA - Tracking ID
You can choose variable type RegEx Table
Set the Input Variable to {{Page Path}}
And set the rows you need to the following:
Pattern
^/en/.*
^/de/.*
^/fr/.*
Output
GA-2
GA-3
GA-4
Under Advanced Settings
Check Ignore Case, and uncheck Full Matches Only and Enable Capture Groups...
Now add this variable {{UA - Tracking ID}} in your Universal Analytics tag under Tracking ID.
This will work on the tracking for each language.
When that's done, I will just add an extra Universal Analytics under Tags that tracks all the pages with the tracking ID GA-1.
Now two tags will be fired on eg. domain.com/en/, one for the combined domain GA-1 and one for the separate domain, in this example GA-2.
I am using Google Analytics and would like to see how users interact with my site, mainly what internal links they are clicking and from where.
One approach I've found is to add queries to my links like so ?ref=sidebar or ?ref=featured
Another approach is to use Event Tracking _gaq.push(['_trackEvent', 'Article', 'Click', 'Sidebar']);
I am wondering: Is there any reason to use one approach over the other? I know Event Tracking can be used to capture Javascript events, which queries cannot. But most sites I've seen also uses Event Tracking on their links, instead of simply adding a query string. Why is that?
Query Strings make different unique urls. So if you add query strings to your pages the pages report will show multiple entries for (basically) the same url depending on how people got there, e.g.:
subsite.html
subsite.html?ref=sidebar
subsite.html?ref=featured
each with it's own pageview count and other metrics.
Usually you do not want this. Event tracking is better since it does not blow up the url count (there might be be even better ways, especially if you upgrade to Universal Analytics and use custom dimensions).
I'm just getting started with splittesting using Google Analytics (GA). Rather then using different URLs for different versions of a page I want to use the same URL and differentiate the versions via GA custom variables.
I've managed to accomplish this in my Django project with a conditional in the view-layer that loads up different html templates for different versions and the html-templates also take care of setting the custom variables.
However I think that it would be a lot cleaner to have all of my splittest code in a javscript file that:
1) Sets/reads a cookie on the browser specifying which testing bin this browser is in.
2) Modifies the page html and css to create the different versions
3) Records the version in a GA custom variable
Right now I'm setting all of my custom variables right in the code snippet that I've copy-pasted from GA.
My question is simply: Can I set the custom variables later in the page buy a _gaq.push(), or do they need to happen before the anonymous function that ends the snippet from GA?
Custom variable data gets recorded when GA makes a tracking GIF request, which occurs with _trackPageview or _trackEvent.
So, you can set the custom variables anywhere in the page, as long as there's a _trackPageview or _trackEvent somewhere afterwards.
I've recently learned about the new Google Analytics Content Experiments which looks interesting. ( http://analytics.blogspot.nl/2012/06/helping-to-create-better-websites.html )
The standard usecase seems to be that for a certain page, say a product detail page, you supply variations (different urls) and select a percentage of users that are included in the test. Such a user will be presented a variation of the product-detail page (and will continue to be presented the same variation over and over for continuation/ux reasons, based on cookies presumably) .
All fine and good.
However, say I have 100 products on my site. Just testing a variation on 1 of those products has imho the following disadvantages:
slow progressing tests because of lower nr of visitors.
the test isn't isolated. I.e: since other product detail pages aren't included in the test, displaying a variation-page for 1 product-detail page while all other product-detail pages show the original can (will) lead to a confusing experience (and thus skewed conversion statistics) for the user that browses multiple products, which most of them do.
To me it seems far better to be able to dynamically include all products of a certain type into the same test (e.g: all TV's) , for example by enabling to set some regular expression or other filter on urls to include in the test.
Is such a thing possible currently, scheduled, useful, or completely missing the point?
EDIT
Part of the solution seems to be "relative urls"
https://support.google.com/analytics/bin/answer.py?hl=en&answer=2664470
Taking the previous example one step further, we can see how the use
of relative URLs lets you easily run an experiment on a set of
different original pages, and test visual alternatives across that
group of pages (e.g., the product pages in an e-commerce site).
Remaining question: How to dynamically tag which pages belong to the experiment (e.g: based on regex)
Thanks.
The solution is to use relative url for the variation page.
E.g. you have a number of product pages:
www.mysite.com/products/eggs.html
www.mysite.com/products/cheese.html
www.mysite.com/products/bread.html
etc.
For each page you have a matching variation page:
www.mysite.com/products/eggs.html?var=bigpicture
www.mysite.com/products/cheese.html?var=bigpicture
www.mysite.com/products/bread.html?var=bigpicture
etc.
You want to use all the product pages in 1 experiment.
Go To google Analytics Content Experiments:
For the orginal page choose ONE of the many product pages (e.g. www.mysite.com/products/eggs.html) (This is just to get the experiment code and provide GA with an example page)
For the variation page choose relative url and put ?var=bigpicture
Then place the javascript required for the experiment on ALL the original product pages you want in the experiment
For more information see: http://support.google.com/analytics/bin/answer.py?hl=en&answer=2664470&topic=1745208&ctx=topic
Use the Javascript API as described here:
https://developers.google.com/analytics/devguides/collection/gajs/experiments#pro-server
You can set the experimentid programmatically in your code, on every page. Of course you need first to create the experiment in GA, in doing so provide GA fake urls for each variation, discard the GA generated code, ignore the validation errors.
And just use the experimentid as described in the link above.
OK, so a solution to this is:
Create experiment.
Chose a placeholder url for your original url. Something like www.example.com/products/eggs. Set variations as relative urls eg ?var=large_heading, ?var=small_price
Have some mechanism on the server-side which determines if the current user is part of the experiment. A simple cookie is good enough. If this cookie is present show a variation of the page.
If the user visits a product page but isn't in an experiment then show the javascript given when you created an experiment.
Add something to your product page which checks for the querystring var=[something]. When detected show the appropriate variation as well as setting the cookie which tells marks the user as being in an experiment.
You can hack around the JavaScript that Google gives you to make this a bit easier. Something like:
var variation = utmx('variation_code', 'A/B');
if (variation) { set_a_cookie(variation); }
utmx('url', 'A/B');
This is largely cribbed from the GWO Techie Guide. http://static.googleusercontent.com/external_content/untrusted_dlcp/www.google.com/en//websiteoptimizer/techieguide.pdf
There is also a way to the A/B testing with GA without experiment API if you really want to keep things simple. The idea behind it is to create your own split parameter and than you can pass it to GA as a custom variable. So you can yous your own development tools to differentiate the content in the groups and you don't have to use redirect. Here is a simple tutorial how to do this: link.
I recently implemented a GA experiment to test out different text on a nav bar across many pages. This is what worked for me:
Set up the experiment in GA for a single page. E.g. index.html and
index.html?var=menu2.
Implement the solution across multiple pages. Specifically,
insert the GA experiment code in all the pages
that you want to run
the test. Then ensure that your page(s) can render the page
variation based on the parameter passed. My php code went something
like this: If var=menu2, display page with menu2; otherwise,
display original menu.
How would I go about preventing the tracking of hash path changes within google analytics while using the jquery address plugin?
original URL:
/?watch
When moving sliders on the page, address bar is appended:
/?watch#/204;276
Within analytics I'm seeing it tracked as unique page views like so:
/?watch/204;276
I'm just wanting it to be tracked as:
/?watch
Help much appreciated.
You could use a custom search and replace filter with a regular expression in the search string.
Before setting up any filters, make a "master" profile in GA that contains unfiltered data. That way if your filter affects your data negatively, you have all your data unfiltered and backed up.
The regular expression I used is ^/\?watch[/0-9;]+ You can test it at RegExPlanet. I didn't put the hash (#) symbol in the regex because, according to your question, GA is not tracking it in the request URI.