WooCommerce tracking variable product views/selects - javascript

I'm just working on the tracking of woocommerce variable products with google analytics. Tracking simple products is not a big deal, because every page view is a product. However for me it's pretty interessing to know which product variations users looked at.
I need some similar stats for variable products. Which variable products did the users look at? My products do have quite some variations since one product has about 7 attributes.
I think it shouldn't be to hard to hook into the drop down selects of woocommerce variable products with js and fire on select.
How would you track the product variation views with google analytics?
I don't want to mix page views, sales and on the other hand view of product variations too much. I'd rather prefer to track the views of variations through events into a different view (or property). How you get those events into one view and everything else in the default view?
How would you track the parameters to be able to analyse them? My main filter will be product, than I want to filter on different attributes and see how the other attributes cluster on user impressions.
Anyone already has a script for this?

You can just add event handler for 'found_variation' in JS. That is woocommerce event for selecting variation.
And then use analytics built in function:
https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide
jQuery(document).ready(function($) {
$(this).on('found_variation', function(event, variation) {
_gaq.push(['_trackEvent', 'Variation', 'Select', variation.variation_id]);
});
});
Haven't tested it but in theory it should work.
And just check variable 'variation' to see what info is available.

Related

How do I filter across Tableau workbooks through the dropdowns?

Please be patient with my English, and it's my first time to be here. I am very new to Tableau and JavaScript as well. I am trying to find a way to filter the dashboards in a different place. For example, when I click a person name from a list on the first dashboard and it shows a result, once I click another dashboard from the drop-down (not on API, just come from an HTML nav bar), this dashboard should show any results with the person name I chose on the first dashboard.
Like this: I'm viewing Dashboard 1. I apply filter Anthony. Then I go to Dashboard 2 after clicking this on drop-down. IF Dashboard 2 also has a filter named exactly "Anthony" show the result automatically.
I tried to research about this, but it does not help very much. I read the API reference and I thought getFilterAsync() from FilterEvent Class would work, but it doesn't. I would appreciate if you can explain or show an example with Javascript codes constructively. This example is similar to my goal, but I don't plan to use two dashboards and textbox/button on the same page. Another example is sort of what I want, but I don't need to put specific values on method to filter. I need to filter across workbooks after clicking anything on the API. It's not just a person name. It can be a date, number, location, etc. I want to know how I make filter values/parameters active on any dashboards.
Any response will be helpful. Thank you!
use action filter, where you specify the source dashboard and then the target dashboard

Button to open new page and auto fill some form elements

I sell a tremendous number of products that require finance of one kind or another. I also use 8 different lending sources for financing. Problem is that each lender works with certain product types and ages, etc. I can not use a generic application form due to the differences in each lenders requirements. I have added APPLY NOW Button(s) to each individual product but cannot use simple "goto" link.
Example(s):
Customer 1 views product ID#20, unit is 20 years old and only one particular lender will work.
Customer 2 views product ID#55, unit is brand new and all will work with it, but I send all new products to one lender in particular.
Apply Now Button is always the same image, but I need for the button to open the application page specific to that product, and auto fill the input fields such as Vendor Name, Product Name and Description, Price, Etc as most customers are unfortunately lazy and simply won't do that once they have been taken away from the product page. I figure I will need to code the button individually based on individual products to open the correct application, but want all to fill in the information. All items for AutoFill are stored in the Store Database as well as the Vendor (Store) Info.
Maybe I am in the wrong area or simply missed the answer somewhere else, but I am getting snow blind trying to find the answers...even a point in the right direction would help.
It sounds to me like you need to link the product with a lender type, this would make it easier to grab lander data and auto populate the form fields when the page loads. This way you would not need to change the "Apply Now" link.
In short I would suggest creating a link table between product/product type to the lender table.

Track which inbound link was clicked in google analytics

I have a website and I'm using Google Analytics.
I have widgets for popular posts, latest posts, posts list, etc...
I want to know if the user clicked on the link in the popular posts widget or the latest posts widget, for example, before getting to that post page.
I can change the link to something like:
example.com/post?ref=popular
example.com/post?ref=latest
example.com/post?ref=search
But I don't want those to be treated as different pages.
How can I do that?
Given that you are looking to simply count the number of times someone clicks on the links, then you want to use Google Analytics Event Tracking: http://davidshawblog.com/2013/01/18/google-analytics-event-tracking/
You need to add an onclick event to your links and provide a name for them, e.g.:
onClick="_gaq.push(['_trackEvent', 'Popular Posts', 'Clicked', 'Post Name']);"
Hope that helps

Google Analytics: Tracking multi categories where a page belongs

I have a content driven website, where each content item belongs to many different categories.
For example, article "A" belongs to the categories "cat1", "cat3", "cat4" and article "B" belongs to the categories "cat2", "cat3", "cat4".
The number of categories is very big (around 800) and the number of articles more than 10.000.
I want to know all the pageviews of articles that belong to a given category.
Researching google analalytics I didnt find any tool that allows me to do that.
I investgated if I could misuse the campaigns to do it, but the only way would be to rewrite the urls (in order for the campaigns to work), and I dont want to touch my very nice urls.
I tried doing it with events, but it was messing up my bounce rate (since an event meant that the users were actually doing something, so the page was not counted as "bounced").
Has anyone any idea of what I could do to record my categories?
The same solution could be applied to tags in a blog post. (Lets say you wanted to know all the pageviews of all blog posts that have the tag "travel").
Thanks
Koyan
Ok, I didnt manage to do exactly what I wanted, but canibalising the custom fields I managed to do something very close.
I put in my ga code the following:
_gaq.push(['_setCustomVar', 1, 'Cat', '-coats-winter-red-used-light-pockets-', 3 ]);
Where coats, winter, red, used, light, pockets are the tags (categories) of that page.
I use php to produce this string.
An other page would have the following for example:
_gaq.push(['_setCustomVar', 1, 'Cat', '-dress-winter-blue-new-light-pockets-', 3 ]);
And all these got pushed to a single variable. Now, I cannot find which of the tags has the most hits (the one part of the report I wanted), but I can find how many hits a certain tag has.
To do that, I created a custom report, where I put the metric group "pageviews" and the Dimension drilldowns "Custom Variable (Key 1)", "Custom Variable (Key 1)
Custom Variable (Value 01)", "Page"
Then I run the report, click on the variable "Cat", and filter for -winter- and it gives me how manypageviews I had for articles with the tag "winter".
Dissadvantages:
a) There is a limit of 64 bytes for the combination of custom variable name and value. I have overcome this by not using actually the tags, but their id's
(so, in my real scenario, the values look like -31-39-45-130-168-206-249- but this is good enough for me).
b) You cannot find from inside google analytics which category/tag has the most pageviews.
(you can always export it though to a csv and work on it in an other script).
Hopefully Google will add a "tags" functionality sometime in the future (am I the only one needing this?)
One potential solution would be to use custom variables. For example:
Category1 = Coats
Category2 = Winter
Category3 = Red
The two limitations of this solution are that you are limited to five custom variables per page and that your google analytics queries would get fairly complex as you would need to search across all the category variables to find the specific value you're looking for.

Dynamically display Edit Control Block menu item in SharePoint

I am trying to set up dynamic per-item menus (Edit Control Block) in SharePoint 2007. My goal is to have certain features that are available based on the current user's group membership.
I know that the CustomAction tag that controls the creation of this menu item has a Rights attribute. The problem that I have with this is that the groups I am using have identical rights in the site (ViewListItems, ManageAlerts, etc). The groups that we have set up deal more with function, such as Manager, Employee, etc. We want to be able to assign a custom feature to a group, and have the menu items associated with that feature visible only to members of that group. Everyone has the same basic site permissions, but will have extra options availble based on their login credentials.
I have seen several articles on modifying the Core.js file to hide items in the context menu, but they are an all-or-nothing approach. There is an interesting post at http://blog.thekid.me.uk/archive/2008/04/29/sharepoint-custom-actions-in-a-list-view-webpart.aspx that shows how to dynamically modify the Actions menu. It is trivial to modify this example to check the users group and show or hide the menu based on membership. Unfortunately, this example does not seem to apply to context menu items as evidenced here http://forums.msdn.microsoft.com/en-US/sharepointdevelopment/thread/c2259839-24c4-4a7e-83e5-3925cdd17c44/.
Does anyone know of a way to do this without using javascript? If not, what is the best way to check the user's group from javascript?
There are two different Javascript functions that you can implement for dynamically adding menu items to list item drop downs. Core.js (C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033\CORE.JS) checks for the existence of these methods when generating the menu items for a selected list item. "Custom_AddDocLibMenuItems" and "Custom_AddListMenuItems" are the names of the Javascript methods.
One article that I think you can use to solve your specific problem, dynamic menu item customization based on user role membership, can be found here:
MSDN: Customizing the Context Menu of Document Library Items (note the process is exactly the same for any list type)
This article outlines how server side code can be executed to define the menu items that will be displayed:
[...] in more complex cases, you must retrieve the list of available commands from the server, because only there you can run your business logic and perhaps get the commands from a custom database. Typically, you want to do this if you are implementing a workflow solution where each document has its own process state, with commands associated to it.
The solution for this situation is to have the Custom_AddDocLibMenuItems dynamically call a custom ASP.NET page. This page takes the ID of the document library and the specific item on the query string, and returns an XML string containing all the information for the commands available for that particular document. These commands are available according to the document's process status (or some other custom business logic). [...]
Unfortunately this is not possible to accomplish without using javascript. The ECB doesn't render server controls defined as a custom action (unlike the SiteActions etc).
To learn how to accomplish this by using Javascript check out the following article:
http://www.helloitsliam.com/archive/2007/08/10/moss2007-%E2%80%93-item-level-menus-investigation.aspx

Categories