Google Analytics: Set content group when sending virtual pageview - google-analytics

Is it possible to set a content group for a virtual pageview?
As a user moves through the stages in my one page checkout I use virtual pageviews to track their progress in Google Analytics, like so:
// Moves to address section
ga('send', 'pageview', '/checkout/address');
// Moves to payment section
ga('send', 'pageview', '/checkout/payment');
Throughout the site I use content grouping to group similar pages together, using the tracking code method e.g.
// Product pages
ga('set', 'contentGroup1', 'Product ');
// Category pages
ga('set', 'contentGroup1', 'Category');
I want to do the same for the checkout so I can report on all of these pageviews together if required.
Is there a way to set the content group for a virtual pageview using tracking code?

You should be able to set the CG for your VPVs in the same way that you set it for your normal page views. Just remember that when you use the set method, it will apply to all hits until it is changed or until you load another page.

Related

Single Page Application Tracking with Analytics: no virtual pageviews in dashboard

I'm trying to use some virtual pageviews on my single page application (Angular)
I set the js code as follows:
ga('set', 'page', pageviewurl);
ga('send', 'pageview');
where the var pageviewurl could be something like:
'/form/w/toyota?from=hp#step=2__from=js'
But I'm not able to see anything related these virtual pageviews on Analytics dashboard...
am I doing something wrong?
Or in which section of the dashboard can I get pageview data?
Thanks
I answer to my question just to confirm that the js code is correct.
After some time, by accessing to Analytics dashboard, virtual pageview data is visible in the section Real time -> content

Google Analytics Search Metrics

I need to implement google analytics search metrics. I have a ecommerce site. My requirement is that when i search for categories a list of products appears. Every product has like/ unlike button.
I need to track number of likes per search in google analytics.
Is this doable by google analytics ?
Please suggest!
You should use event tracking.
Events are user interactions with content that can be tracked
independently from a web page or a screen load. Downloads, mobile ad
clicks, gadgets, Flash elements, AJAX embedded elements, and video
plays are all examples of actions you might want to track as Events.
To fulfil your requirement, you could implement the event tracking as follows:
ga('send', 'event', [eventCategory], [eventAction], [eventLabel], [eventValue], [fieldsObject]);
// you may add this implementation, says when someone like a product:
ga('send', 'event', 'Products', 'like', 'Search Page');
// or when someone unlike a product
ga('send', 'event', 'Products', 'dislike', 'Search Page');
If you have unique URL and PageView Tracking for each search, you have done and can view the metrics on Events > Top Events, with second dimension Page, filtered by search page.
Otherwise, you should setup Site Search. Send the pageview tracking manually as follows:
analytics.js: ga('send', 'pageview', '/search_results.php?q=keyword');

Google Analytics: send Content Grouping without a pageview?

I am implementing Content Grouping on my Wordpress website using the tracking code method.
I understand from the official documentation that the tracking code should be inserted before a pageview, that is,
ga('set', 'contentGroup1', 'Blog')
alone won't fire but
ga('set', 'contentGroup1', 'Blog');
ga('send', 'pageview');
will. My question is:
Is there a way to send the grouping information without relying on a pageview?
I have tried sending an event rather than a pageview, but it didn't work.
I am asking because I am using a Wordpress plugin to inject the default GA tracking code, and I would like not to mess with it.
Thank you for your time!
Content groupings can be applied to events, and not just pageviews. When you send in an event hit, you can go to the Events > Pages reports to see if a particular page associated with an event falls into a specific content grouping.
One of the caveats is that the content groupings report under Site Content > All Pages report is different from the Events > Pages report. The former categorizes only pageviews, whereas the latter categorizes pages associated with an event.
Note that if you use the 'set' method to set the content group as you've done before the pageview hit, all subsequent hits for the page (events, pageviews, transactions, etc.) will be associated with the specified content group (ie. "Blog").

Can I pass google analytics marketing tracking code to a following page (when the landing page doesn't have GA code)

I am in a scenario where we are tagging up on part of the site (purchase.mysite.com) with GA tags but we aren't tagging up the main site (www.mysite.com).
The problem is that a lot of traffic that goes to purchase.mysite.com initially goes via www.mysite.com which means if a user lands on www.mysite.com with a marketing tracking code and then goes to purchase.mysite.com the tracking code will be lost and all traffic from this route will be considered referral.
Is there a way to still pass this marketing campaign code when the user hits purchase.mysite.com (other than adding GA code to the main site which we don't want to do)?
If not possible in GA, is there another technical solution like saving the tracking code in the cookie and then setting it when the user goes to purchase.mysite.com?
Any help would be greatly appreciated.
Thanks,
Frank
Frank,
Your final paragraph htis the nail on the head: save your campaign tracking data into your own cookie and then read this cookie when you're on a page with GA on it and manually set the campaign data. You only need to set it once and it will then propogate through for the whole session/user as per your requirements.
To set the campaign data manually, just use code such as this (ref: https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#campaignName)
ga('set', 'campaignName', 'My Campaign Name');
ga('set', 'campaignSource', 'anotherwebsite.com');
ga('set', 'campaignMedium', 'cpc');
ga('send', 'pageview');
notes
You must set at least Source & Medium for the data to register with GA
Medium has a fixed set of possible values as per this google doc: https://support.google.com/analytics/answer/1033173?hl=en

Google Analytics Custom Dimension Not Being Set

I've recently upgraded our site to use Universal Analytics and am trying to get some custom dimensions to work. However, no custom dimension data appears to be logged. Below is an example of my code.
ga('create', 'UA-XXXXX', 'test.com');
ga('send', 'pageview');
ga('set', 'dimension1', '149377');
Do I need to set custom dimensions before sending pageview?
A dimension is sent along with the either a page view or an event. It won't get sent by itself. So you should switch the order of the 'send' and 'set', then look in the network to see the page view call and you should see the dimension as one of the parameters.
Note that you will see the dimension data in google analytics with a delay of a day or so.
I had the same problem, took me a while to find out its cause...
That's correct by the way, that is you must do the SET before the SEND.
Here is the official documentation (see section "Collection"):
[...] Unlike other types of data, custom dimensions and metrics are sent to Google Analytics as parameters attached to other hits, like pageviews, events, or ecommerce transactions. As such, custom dimension or metric values need to be set before a tracking call is made in order for that value to be sent to Google Analytics.
For example, to set a custom dimension value, your code might look like this:
ga('create', 'UA-XXXX-Y', 'auto');
// Set value for custom dimension at index 1.
ga('set', 'dimension1', 'Level 1');
// Send the custom dimension value with a pageview hit.
ga('send', 'pageview');
Cfr. https://support.google.com/analytics/answer/2709828?hl=en

Resources