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).
Related
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.
I have two regex that I need to join into one as I am using the RegularExpressionAttribute in ASP.NET and it does not allow multiple instances.
How can I join the following two regex into one?
.*?#(?!.*?\.\.)[^#]+$
[\x00-\x7F]
the first one checks that there are not 2 consecutive dots in the domain part of an email and the second regex checks that all characters are ascii
I thought it might have been as easy as joining them together like (.*?#(?!.*?\.\.)[^#]+$)([\x00-\x7F]) but this does not work
Here is link to previous post relating to this problem
EDIT: I am decorating an string property of my viewmodel using reglarexpression attribute and this gets rendered into javascript using unobtrusive therefore it has to validate using javascript. I failed to mention this in my initial post
You can use:
^[\x00-\x7F]+?#(?!.*?\.\.)(?=[\x01-\x7F]+$)[^#]+$
You can just use this regex
^[\x00-\x7F-[#]]*?#(?!.*?\.\.)[\x00-\x7F-[#]]+$
Or, if you want to match at least 1 character before #:
^[\x00-\x7F]+#(?!.*?\.\.)[\x00-\x7F-[#]]+$
Mind that [\x00-\x7F] also includes # symbol. In C# regex, we can subtract this from the range using -[#] inside the character class.
And you do not need the anchors since you are using this in a RegularExpressionAttribute, I believe.
Here is a demo on regexstorm.net, remove the second #, and you will have a match.
We have a large website that is split up into groups of organisations with a number of micro-sites. We would like to provide one organisation within a group with their own set of data and I am having troubling getting the filtering working.
I think my main problem is I have 2 include filters. According to the documentation:
"If you apply multiple Include Filters, the hit must match every applied Include Filter in order to save the hit."
Our website urls would go something like this: https://[host]/[group]/[site]/[params]. I would like to track the following, given that this client (id 9) is in group "foo":
https://mysite.com/foo/live/default.aspx?id=9
https://mysite.com/foo/live/?id=9
https://mysite.com/foo/reporting/9/*
so that any hits on those urls would be captured for this particular client.
Our 2 current filters (type="Include") are as follows:
/foo/Reporting/9/
/foo/[^\?]*\?id=9
but these do not seem to track everything we think they should. Any help would be much appreciated.
By the time the first filter is done there is nothing left for the second filter to match - the first filter throws everything away that does not match (that's what Google means by "the hit must match every applied Include Filter").
I would suggest you first use an advanced filter to transform your urls so they follow all the same pattern (i.e. grab the value from the query parameter and append it to the url path) and then apply the include filter. I'm pretty certain that would be easier than trying to include different url structures (if you need help with the filters holler away in the comments, but the example given in the advanced filters interface should give you a clue how this works).
I have a template which uses the same multivalued attribute in various places. I often find myself in a situation where I would like to filter the attribute before a template is applied to the individual values.
I can do this:
<#col:{c|<if(cond)><# c.Attribute2 #><endif>};separator=\",\"#>
but that is not what I want, because then there are separators in the output separating "skipped" entries, like:
2,4,,,6,,4,5,,
I can modify it to
<#col:{c|<if(c.Attribute1)><# c.Attribute2 #>,<endif>};separator=\"\"#>
Which is almost OK, but I get an additional separator after the last number, which sometimes does not matter (usually when the separator is whitespace), but sometimes does:
2,4,6,4,5,
I sometimes end up doing:
<#first(col):{c|<if(cond)><# c.Attribute2 #><endif>};separator=\"\"#>
<#rest(col):{c|<if(cond)>,<# c.Attribute2 #><endif>};separator=\"\"#>
But this approach fails if the first member does not satisfy the condition, then there is an extra separator in the beginning:
,2,4,6,4,5
Can someone give me a better solution?
First, let me point out that I think you are trying to do logic inside your template. Any time you hear things like "filter my list according to some condition based upon the data" it might be time to compute that filtered list in the model and then push it in. That said something like this might work where we filter the list first:
<col:{c | <if(c.cond)>c<endif>}:{c2 | <c2.c.attribute>}>
c2.c accesses the c parameter from the first application
The answer by "The ANTLR Guy" didn't help in my case and I found another workaround. See at Filter out empty strings in ST4
How to search every word separated by comma in textbox
Please refer above post
Its Working perfectly...But i have small issues.. when i enter in text box like c,c++,4-5 yrs it have to check in database like either c,c++ skills and 4-5 yrs experiecne and then the reult has to be shown... Burt as per ur query it just show results whether any one of keyword satisfy database ...I want to compare year also how? –
If you want that behavior, you have to program that behavior. One design is to have multiple input boxes: one where you check if any of the words exist, another where you check that all of the words exist. (Perhaps even another for an exact phrase match.) Another design possibility would be for you to develop a syntax to indicate optional and required words all within a single input box. The point is it is up to you.
After you've decided on a design, then you could write code that builds your query based on or matches on the optional words and and matches on the required. Something like this pseudocode
Select * From Table Where
(Field Like OptionalWord1 Or Field Like OptionalWord2 Or Field Like OptionalWord3)
And Field Like RequiredWord1
And Field Like RequiredWord2
(etc.)