How to create a custom trigger in Google Tag Manager - google-tag-manager

In Google Tag Manager say you have three different items:
If variable = 2
If URL = abc.com
If URL = def.com
Is there a way to create a single trigger that will mean A AND (B OR C)?
I know I can create A & B in a single trigger and A & C in a single trigger, or the same groupings in a trigger group. Is there a way to create this without creating multiple triggers?

Sure. A trigger responds to an event, so you first have to select the trigger type. Then you add filters so the trigger only activates when certain conditions are met.
All filter conditions in the trigger need to be met to activate the trigger. But your example does not have three different items, it has two different items and one of the items can take two different values. So this becomes a matter of selecting the appropriate match types.
The first variable has one value that is supposed to activate the trigger, so the match type is "equals".
The second variable has two possible values that are supposed to activate the trigger. For this, you can use a regular expression that checks if the variable has either one or the other value. The "or" operator in regular expressions is the pipe character "|". If you want to make sure that this matches only exact strings, you can add the "starts with" character "^" and the "end with" character "$" to the start and end of the respective strings.
This will look something like this example:

Related

check duplicate values in oracle forms multi record block

What I wanted is to display an alert when I move to the next row if the record that I inserted is already one of the records in the multi record block.
and in what trigger must I put it?
There are several options you can use.
One is to POST values entered (in WHEN-NEW-RECORD-INSTANCE) trigger. It will, well, post everything you entered so far. Then, you can write a WHEN-VALIDATE-ITEM trigger which SELECTs from that table and checks whether such a value already exists. Alternatively, if there's the UNIQUE CONSTRAINT on that (those) column(s), database will do its job itself, i.e. raise an exception.
Another option is to literally loop through all rows in a block and compare the first row's value with all the others, then the second row's values with all of them, etc.
Or, you can use a Record Group (usually used for Lists of Values). Basically, you'd check whether value you entered exists in a record group. More info, along with a FMB file, on Craig's blog.
Or, you can use calculated items, as described enter link description here (FMB attached as well).
As you can see, quite a few ways to do that; explore each of them and pick the one you find the most useful / attractive / easy to implement.

Google Analytics doesnt apply my filter

I created a filter on my account.
This filter is a custom filter, search and replace.
I use
"Request URI" for Filter Field,
\?.* for Search String
I also attached this filter to my specific view.
My problem is, if I go to the view->Reporting->Behavior->Site Content->All Pages, I see that the filter is not applied. I see pages such as "/xy.html?id=12345".
I would expect "/xy.html" only. Somewhere I've read that filters are not works for past data, but I did some test visits after I applied the filter and the urls wasn't changed :(
If I click on verify, I get this message: "This filter would not have changed your data. Either the filter configuration is incorrect, or the set of sampled data is too small."
Your filter definition should use regular expressions for search&replace.
Search String: (.)?(\?.)
Replace String: \1
This will search for two parts: 1. all symbols before the very first "?" 2. all symbols after the first "?" in your URI.
The replacement will use the first part as replacement (all symbols before the very first "?"
Make sure you google some regex basics.
Filters only apply the new data collected, never the historic data you already have in your properties collected.

Lookup Table Input Variable Issue

I am using a lookup table to successfully apply different UA-ID codes to the same universal analytics tag. However, for one particular UA-ID, I need to send data from all pages with the exception of data from a particular sub domain. i.e. something like this:
input variable : *.example.com except abc.example.com
Not sure how to implement this logic for the input variable of a lookup table.
Also, if I specify "example.com" as an input variable, does it capture all subdomains?
Edit in Jan 2018 for latest info.
For lookup tables you need to know 2 things:
Lookup table input variables do a hard match. I.e. its simply an 'equals' only, no 'contains' or 'starts with' or regex etc.
Lookup tables are sequential, the matching starts from the top and stops as soon as a match is found. Much like an if then elseif (without an 'else' available at the end!)
You can apply a default value if none of the rows in the table match.
There are now Regex Tables available as well which will enable you to do partial matches on values and return a value based on that. For full and comprehensive details, read the article by Simo
In your case you have 3 options:
Use a Regex Table Lookup
list each and every hostname (inc subdomain) you want to match and apply the correct UA number to each. You should end up with as many lines as you do sub-domains.
Create a new custom javascript variable which inspects the current host (inc subdomain) and returns whether its 'abc.example.com' or '.example.com' (indicating any other sub domain) and then you'll just need a couple of lines in your lookup table.

Profile View Filters Request URI

I'm trying to "Include Only" about 40 URLs for a specific profile view. I set up three Request URI filters that use "Include Only" and the following regex:
FIRST:
/(subdirectory1|subdirectory2|subdirectory3|subdirectory4)/
(That goes on and on for about 15 subdirectories)
SECOND:
/(subdirectory16|subdirectory17|subdirectory18|subdirectory19)/
(That goes on and on for another 15 subdirectories).
THIRD:
Same thing for whatever remains.
If I only have ONE "Include Only" Request URI filter set up this way, it works. As soon as I add a second filter, it stops tracking everything. Unfortunately, I can't fit all URLs in the one filter.
How can I accomplish this?
Thanks.
The first filter includes the subdirectories 1-15 (if numbered sequentially). Everything else is thrown away. The second filter works on what is left, so from the sequence subdirectory1 to subdirectory15 it only includes those that match the pattern subdirectory16-subdirectory25. Which is none of them.
Filters are applied in the order that they are defined and they are destructive, data that has been deleted in a previous filter is not evaluated in a subsequent filter, hence you see nothing.
An standard include filter does not accept regular expressions (whith the exception of the "|" character). However as far as I know (and according to the documentation) the advanced include filter does.
I'm not great with regular expression, but the following pattern should work or at least be good enough to get you going:
\/subdirectory([1-2][1-9]|[1-9])
The first bit is your directory name. The bit in parenthesis should match the numbers. Specifically:
[1-2][1-9]
should match numbers from 11 to 29 (these are character classes, regex treats numbers as characters not as numbers. So this bit looks for something that starts with 1 or two and is followed by one of the numbers 1,2,3,4,5,6,7,8,9).
Then there is your "or"-sign and a second expression to match numbers that have only one digit.
Change the character classes according to your needs.
You'd have to go from predefined to advanced filter, set "include", use "RequestURI" as filter field and enter the expression. That should work (I admit I haven't tested it).

How can I get results for a dimension (custom variables), where the value is not set?

I am using custom variables to track order ids. In order to aggregate analytics data into out data warehouse, I want to select a number of metrics with the custom variable as a dimension. However, if I do so, I will not get the entries where the variable is not set (E.g. sessions that didn't result in a sale). I need to get these as well.
Can I write a filter or segment that selects only the entries that doesn't have a particular custom variable? I have tried:
segment=dynamic::ga:customVarValue1==
But that doesn't seem to work (It gives no results back).
Basically I'm looking for the equivalent to where ga:customVarValue1 is null in sql.
In short, it's not possible to get the nullset data, as explained by a Google rep:
For some dimensions, GA uses the default value of (not set).
Custom Variable do not have a default value, so if a hit does not have a
custom variable associated with it, all the other dimensions in the query
are not added to the reports.
The original answer is a little confusing, but when you read between the lines it suggests that they throw out these "empty" values when they run their aggregates.
The "correct" approach, as he explains, is to set a default value for any row you want reported:
If you need to see the (not set) value, you could try sending a default
value for custom variables.
For example if you use visitor level custom vars to track member vs
non-member, you should always set non-member as a default for everybody;
then modify to member once they register.
Details are here: http://groups.google.com/group/google-analytics-data-export-api/browse_thread/thread/cd078ddb26ca18d5?pli=1
I've just had some success solving this by using a Regex to capture users or sessions where the custom dimension has no value. In my case I want to separate logged in and logged out users.
The Regex .+ will capture any non-empty value, so can be used to get the job done.
The filters for my Returning users segment is matches regex: .+ like this:
For the Customer prospects I used: does not match regex: .+ like this:
It's early days, but this appears to be working:

Resources