Google Analytics advanced segments - excluding by user interest - google-analytics

initialization: company website with product pages and separate ‘careers’ section.
I’m trying to create advanced segment with Google Analytics that would exclude visits that were more focused on careers section.
career URLs are simply:
/careers
/careers/job1
/careers/job2
I tried to use (two statements with AND operator):
‘Exclude’ ‘Page’ ‘Begins with’ ‘/careers’
AND
‘Exclude’ ‘Pageviews’ ‘Greater than’ ‘1’
Is this approach correct?
Or do I get more reliable results if I use TimeOnPage instead of Pageviews?
Example TimeOneSite greater than 15 sec.

You can try this: 'Exclude' 'Page' 'Matching RegExp' '/careers.+$'
It should exclude any visits within the careers section beyond the main careers page.

Related

Google Analytics - Find most popular site directories

I want to be able to track the most popular directories on my site. The site is split as follows:
www.sitename.com/directoryA
www.sitename.com/directoryB
www.sitename.com/directoryC
Each directory has thousands of pages recording views underneath it e.g.
www.sitename.com/directoryA/page1
www.sitename.com/directoryA/page2
www.sitename.com/directoryA/page3
What I would like to is roll up the views from all the pages to create a table of my my popular directories (there are thousands on the site)
How can I do this?
Create a new field in DataStudio with this regex:
REGEXP_EXTRACT(Page,'(/[^/]+)')
This way, you can use this new field to group your counters based on part of the URL.
If you need to analyze other levels, just adjust the regex, repeating /[^/]+:
1st level (/path1): REGEXP_EXTRACT(Page,'(/[^/]+)')
2nd level (/path1/path2): REGEXP_EXTRACT(Page,'(/[^/]+/[^/]+)')
3rd level (/path1/path2/path3): REGEXP_EXTRACT(Page,'(/[^/]+/[^/]+/[^/]+)')
...

Sending multi-level categories in Product data for Google analytics

I'm implementing Google tag manager for product view on web e-Commerce.
In a document from Google, it says about category attribute.
The category to which the product belongs (e.g. Apparel). Use / as a delimiter to specify up to 5-levels of hierarchy (e.g. Apparel/Men/T-Shirts).
So we can send multi-level categories separated by forward slash. But what if category name, for example, is "3/4 inches". How can we escape it to make sure that it will be one-level category name in GA Dashboard.
In additional, if I would like to send 2-level categories:
Level1: Screws
Level2: 3/4 inches
How could we send data in category attribute ?
As I worked around so far, I've tried
In JS, categoryname.replace(/\//g,'\/')
In JS, categoryname.replace(/\//g,'-')
In JS, categoryname.replace(/\//g,'%26')
But I don't know what is the best practice for this.
Thank you in advance.
Link to Stack Exchange question

Google Analytics - How to filter by page, group by query string value?

I have a site with a store search that posts in the following format.
www.site.com/store-locator?city=&province=&zip[postal_code]=68123
I am trying to configure GA to give me feedback on people visiting this page and a count of specific zips searched.
example report data
/store-locator?city=&province=&zip[postal_code]=68123 1000 visits
/store-locator?city=&province=&zip[postal_code]=68456 768 visits
/store-locator?city=&province=&zip[postal_code]=68789 221 visits
note: the 'city' and 'province' values may also be populated (and I will want to mod GA to give similar data on these too).
Can anyone give feedback on how to configure GA to give me data similar to this?
Thanks!
As far as I know, the only way to look at this type of segment historically is using individual segments, which doesn't work well for an arbitrary number of zip codes. However, you can collect this data more effectively as described for new traffic. This comes up often with information like categories, tags, dates, query string variables, etc.
You can create Segments for each zip. This will work for historical analysis, but is impractical beyond a few. https://support.google.com/analytics/answer/3124493?hl=en&ref_topic=3123779
You can also use Content Grouping to create groups. This will not work historically. https://support.google.com/analytics/answer/2853423
The way I've handled this is using Custom Dimensions, which replaced Custom Variables when Universal came out. This also only works for future data.
To use Custom Dimensions, you would pass the zip code to google analytics explicitly when calling the analytics javascript code.
You can pull querystrings with javascript, or echo the parameter using something like PHP as follows:
<?php
if (array_key_exists("zip",$_GET)) { $theZip = $_GET["zip"]; }
else { $theZip = "nozip"; }
?>
And, sending the custom dimension --
ga('create', 'UA-XXXXX');
ga('set', {'dimension1': '<?php echo $theZip; ?>'})
ga('send', 'pageview');
You also need to setup the custom dimension in the Analytics Profile. Docs on custom dimensions https://developers.google.com/analytics/devguides/platform/customdimsmets
/store-locator?city=&province=&zip[postal_code]=68123 1000 visits
Step 1: In GTM, create a new macro. I called mine {{province}}
Macto Type = URL
Component Type = Query
Query Key = province
This will populate the Macro with the value of province from the query string.
Step 2: In your Google Analytics property, define a custom dimension called "province". This will assign an index key to the dimension.
Step 3: In your GTM tag for Google Analytics, you will find Custom Dimensions under more settings. Add a new dimension, apply the index number from #2 and for the dimension select the macro you created from #1
Publish and you are all set.
Now when you look in Google Analytics, you can add a secondary dimension and choose your newly created custom dimension.

Universal Analytics - push multiple values for one dimension and one pageview

I am trying to use google universal analytics and its custom dimensions.
On one page, I want to send multiple values for one (and one only) dimension.
I tried:
ga('send', 'pageview', {'dimension1': 'grumpy cat'})
ga('send', 'pageview', {'dimension1': 'happy cat'})
When I use google API, I can get for my dimension1 all the values I just sent - so it works well.
However I think (I am not sure about it) that I should not send several times a pageview hit on the same page because it would disrupt the pageview metric.
So I tried to use a custom metric (pageview is a metric after all):
ga('send', 'metric1', {'dimension1': 'grumpy cat'})
ga('send', 'metric1', {'dimension1': 'happy cat'})
But this one doesn't work at all :(
It seems ga.('send'... only accepts pageview but it is weird (why specify pageview in the arguments if it is the only value possible?)
How can I solve my problem? Is it just a syntax issue, is it not possible with custom dimension / custom metric? Can I actually use pageview to do it? Should I use custom events instead of that?
Thank you!
* edit *
I actually found out that I may use an event with a label like:
ga('send', 'event', 'cat', 'view', 'grumpy')
ga('send', 'event', 'cat', 'view', 'happy')
(If anyone can confirm it or have comments I would be happy with that)
I had a similar problem a while back. The thing is, you cannot push multiple values to a single custom variable (dimension or metric) in both Google Analytics (GA) and Universal Analytics (UA). What happens when you push more than one value to a custom variable, dimension, or metric for a single page (or session or user, depending upon the scope of the custom variable, dimension or metric, if you're using UA) is that the last reported value is the only one that is recorded. The last value overrides the previously set value. So, you have tried to record two pageviews with 2 different values for your custom variable (or dimension).
In your case, say a person loads a search results page after having included two categories, grumpy cat and happy cat, and you want to record both of them in a custom variable or dimension by reporting the variable (or dimension) twice, and if you send them in the order you mentioned,
ga('send', 'pageview', {'dimension1': 'grumpy cat'});
ga('send', 'pageview', {'dimension1': 'happy cat'});
you are simply recording two different pageviews (which will skew your reports in innumerable ways, depending on the number or categories you may have). For example, if a person visits more than 5 categories, you will have duplicate pageviews, and your time on page will be drastically reduced, as according to UA (or GA) these pageviews (except for the last one) would have lasted for less than one second.
Also, any events you wanted to link to those custom variables (or dimensions), would only be linked to the last pushed pageview or custom variable (or dimension). As an example, if you had an event tracking set up to identify how many people interacted with the search results, and if you then wanted to filter by category (dimension1 in your case now), to know how many people interacted with the page when dimension1 equals grumpy cat you would get 0, as the events would have only been recorded for the pageview with ddimension1 equal to happy cat because that was the page which GA (or UA) thinks the user had been viewing when firing the event, and that page only had dimension1 set to happy cat. Since those two calls are async, you would actually never be able to know if the events were sent to the pageview you think it went to, even as I explained.
The better way to record this type of data would be to use url-encoded category names, space separated, and a space appended to the end of the list also. As an example, you must send the pageview as,
ga('send','pageview',{'dimension1':'grumpy-cat happy-cat '});
or better, as,
ga('set',{'dimension1':'grumpy-cat happy-cat '});
ga('send','pageview');
Note the space at the end also. This extra space allows you to filter any report based on the custom variable using the reg-ex <categoryName>\s. As an example, to find out how many people viewed a page with category Grumpy Cat, you will filter your report such that the dimension1 matches regex grumpy\-cat\s. I have escaped the - character in regex using \-, and \s stands for a whitespace character. The good thing is, such a report will fetch you all pageviews (or whatever you want to look at), those with only the grumpy cat as category name, as well as those pages which have grumpy cat in the categories to which a page belongs.
A way to add subcategories is to send dimensions as cat1 cat1-subcat1 cat1-subcat2 cat2 cat2-subcat1 so that the regex cat1\s will take care of all category level pages, whereas the regex cat1 will take care of all pages which have category cat1 or which have a subcategory belonging to cat1.
Hope that helps. :)
On a side note, using events for views of a page containing a category is not a nice way of recording it. Because, if you assign dimensions (and this is one of the reasons why custom dimensions were introduced, as different sites have different categories and Google can't name all), your events will also carry the dimensions of the page and it helps a lot to identify which categories are in need of what, by simply segmenting your reports by, in your case, dimension1. For example, you will get to know which category has highest SEO visits and which has the best conversion rates, and stuff. Happy analysing! :)
As it's already stated previously, you can not push multiple values at once. However, this is just an indication the approach to collect events data is not right, that is this is not a page view event anymore. My case was different, but the solution breaks down as follows:
You have multiple values to push into UA at once, say cat's features such as white, grumpy, hungry
Now, you actually realise that this is not a page view event, but rather yet another dimension - cat views/conditions/features - name it whatever you like;
You create a custom event in your GTM, called 'cat-condition';
You create a new tag in GTM collecting cats condition;
You create that custom dimension in GA and GTM, and every time you have to record cats condition you do something similar to the following (extremely simplified code sample)
['white', 'grumpy', 'hungry'].forEach(condition =>
dataLayer.push({event: 'cat-condition', condition})
)
Code snippet assumes you have GTM container configure on the page to enable dataLayer.
Finally, create a custom report in GA to deal with cat conditions. Surely, you can push more details with every single cat's condition to be able to relate it with the page details etc, but this way you have quite a flexible solution with the data being normalised right from the beginning.

Google Analytics Funnel is Not Reporting

I'm having a problem with Google Analytics with the funnel report. Currently I'm tracking transactions but my funnel report is showing that no one is entering the funnel. I have a tricky set up.
1) We are using a third party vendor to run our shopping cart and ordering process they want their tracking code on the site and we want ours.
For example:
_gaq.push(
['_setAccount', 'UA-10187XXX-1'], // OurDomain.com GA property ID
['_setDomainName', '.OurDomain.com'],
['_setAllowLinker', true],
['_setAllowHash', false],
['_trackPageview', '/customer_shopping_cart_funnel/personal_info_customer.html'],
['b._setAccount', 'UA-12670XXX-3'] // vendors GA property ID
, ['b._trackPageview', '/customer_shopping_cart_funnel/personal_info_customer.html']
);
2) Once someone enters the ordering process some of the urls do not change. I tried using _trackPageView like this:
// example for each step
['_trackPageview', '/customer_shopping_cart_funnel/step1.html']
['_trackPageview', '/customer_shopping_cart_funnel/step2.html']
['_trackPageview', '/customer_shopping_cart_funnel/step3.html']
['_trackPageview', '/customer_shopping_cart_funnel/order_confirmation.html']
3) This is how the funnel should go:
User lands on page to chose country for ordering process
User enters shopping cart
User selects products (User is able to visit multiple products)
User enters in buying information
User reviews order and submits order
Order confirmation page
The problem I have is that we need to track from the page that shows the flags, but within the shopping experience they can move around to several pages.
With the funnel, from what I understand, you need to specifically list all of the steps. What I did is assigned each product page the same _trackPageView value so the step was always the same.
What can I do here to get the funnel to report correctly?
Are you able to track these pages in other reports? If so, I imagine the problem is with how your goal funnel is set up.
Ensure the URL's you've set for each step are correct, and match just as they are listed in your reports. If you're using a profile filter to change how URL's are shown in your reports, make sure to take that into account. It might also be a good idea to mark the flag page as being a required step, as well.
As for specifically listing all of the steps of a funnel, the pageviews that take place during the visits do not have to match the exact sequence of the funnel to count towards the funnel and goal.
As an example, lets say your funnel is step1 > step2 > step3 > order_confirmation.
A sequence of page views including additional pages not specified in the funnel, such as, step1 > step2 > step3 > contact_us > order_confirmation, will still count toward the goal funnel.
Additionally, as long as the first page of the funnel was viewed prior to reaching the goal, Google Analytics will artificially backfill the missed pages to have at least as many views as subsequent ones.
Using the same example funnel as above, visiting the pages step1 > step3 > order_confirmation will still count as meeting the funnel goal, even though step2 was skipped. And, step2 will be "backfilled" as having been viewed even though it wasn't.
Thus, Google Analytics will display any visit that includes a pageview of step1 prior to a pageview of order_confirmation as matching every step of every funnel that has step1 as the first step and order_confirmation as the Goal URL. This means that assigning each product page the same _trackPageView value is unnecessary for the goal funnel to track properly.

Resources