Sending multi-level categories in Product data for Google analytics - 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

Related

Inserting a custom handler anywhere in a wordpress URL

I have some custom posts that I need to be able to list and link to at various points around a site.
They are case studies and I want to make them contextually relevant to services, which are currently just pages.
Ideally I want to be able to insert 'case-studies' into a URL, have it recognised and then either list relevant posts if there is nothing following it, or display the post based on the slug that follows case-studies.
EG:
/service1/case-studies - lists all case study posts relevant to service1
/service1/case-studies/blah displays the 'blah' case study post
In the above service1 is just a page. The URL might even be
/service1/subservice/case-studies
/service1/subservice/case-studies/blah
I'm thinking that relationships will handle the relevancy - so a case-studies listing will look up all case studies related to the slug preceding 'case-studies' in the url (so in these cases subservice or service1)
I've looked at wp-router (https://github.com/jbrinley/WP-Router) but I'm not sure how I can use the slugs preceding the case-studies marker to query for relevance.
Anyone had any luck with useful URL routing in Wordpress?

Gravity form does not correlate correctly when publishing a post

There is a problem, I do not know how to solve it.
The scheme is as follows.
There are categories of goods, in this form:
Category-1(term_id=1)<br>
subcategory-1(term_id=4)<br>
subcategory-2(term_id=5)<br>
subcategory-3(name Tour)(term_id=6)<br>
Category-2(term_id=2)<br>
subcategory-1(term_id=7)<br>
subcategory-2(name Tour)(term_id=8)<br>
https://docs.gravityforms.com/creating-a-feed-for-the-advanced-post-creation-add-on/
Gravity Forms will initially look for the category/tag of the same name as specified and use that. If no match is found, then a new category/tag will be created. All new categories/tags created this way will be placed at the top level of the category/tags hierarchy.
I tried everything in the Populate Anything settings, I can’t get it to correlate with the category that I need.I need this (subcategory-2(name Tour)(term_id=8)), inserts here anyway (subcategory-3(name Tour)(term_id=6))
By the way, I'll add one more thing.
https://github.com/gravitywiz/snippet-library/blob/master/gp-populate-anything/gppa-display-terms-hierarchically.php
It would seem that he chose the category that is needed, how to force the search not by name, but by term id?

Algolia - WordPress custom ranking attribute by taxonomy / term

I have list of events that are correctly indexed into Algolia. I would like to be able to "order by" taxonomy/term.
1) first taxonomy is called events_weight (5 terms 1,2,3,4,5). I need the events to be able to order by the term displaying the ones that are 1 at the top and those that are 5 in the bottom. Is this at all possible?
2) second taxonomy is called events_status (active, inactive, promotion). Again I need to be able to order them. Promotion first, then active, then inactive. Is this possible?
Thank you
In your Algolia Dashboard, you can add the events_weight attributes as custom ranking.
For events_status, I would recommend you to convert the values to an integer, to use it as a custom ranking (or sorting).
You can add them both and decide which one go first. This video explains Algolia's tie breaking algorithm.

Google Analytics advanced segments - excluding by user interest

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.

Create a Drupal view that loads all articles that share any one taxonomy term (Contextual Filters)

I have a custom article type that contains a list of taxonomy terms
For example articles can be tagged with a location and possibly multiple topics.
On any given article's display page I would like to be able to pull a single view that gives a list of other articles that share any of of the taxonomy terms.
If an article was tagged with the topics of recipes & chicken as well as the location of new york I would like my single view to present the five most recent articles that share any one of the above tags.
The taxonomy terms have been added to the articles in the form of new fields of either the "Term reference" or "Node Reference" type. (field_topic, field_location)
I know that I have to somehow use a Contextual Filter, but I am having some trouble figuring out how to set and debug my "default argument".
I suspect that I've got to choose:
Taxonomy term ID from URL
Load the default filter from the node page
Do something with PHP code
I'm really struggling to get this displaying anything, and I can't even see a way to debug to find out what the values I'm getting are.
Can anyone help figure this out? Even some guidance on the right direction to look would be welcome at this point.
You can do this in just clicks if you have Drupal 7 and Views 3 (You already have this I'm sure).
Your configuration is correct so far.
Choose " Provide default value " as action to take if arg is not given.
Choose Term ID from URL"
Check "Load default filter from node page, that's good for related taxonomy blocks"
:)
this will load term IDs from the current node's term reference field if arguments are not given.

Resources