Scenario 1: IPv4 only
Scenario 2: IPv6 only
Scenario 3: IPv4 + IPv6 dual stack client AND IPv4 server
- Client will fetch resources from server using IPv4.
- Client will hit Google Analytics using IPv6.
IPv6 Filtering Conclusion
Google Analytics will always abbreviate/shorthand the IPv6 address, so the corresponding filter must also target the abbreviate/shorthand expression of an IPv6 address or block. Note: this is not an official notice, it's just a conclusion based on experimentally trying different representations of an IPv6 exclude filter.
- The reason my initial attempts at writing a filter failed was because my filter regex was not fully in abbreviate/shorthand form.
- When dual-stack is a possibility, filter for both IPv4 and IPv6 blocks.
I just had an experience where I had to figure out how to filter out an IPv6 block, excluding a /56 range. The solution was in fact perfectly straightforward string matching regex.
- Solution -- ^1234:abcd:5:6..:.*$
- A little more clear for human eyes -- ^1234[:]abcd[:]5[:]6..[:].*$
To figure that regex out, I just used a calculator like so -- https://www.ultratools.com/tools/ipv6CIDRToRangeResult?ipAddress=1234%3Aabcd%3A5%3A600%3A%3A%2F56
Note the two period "." symbols after the 6, used to cover the 00-ff range; followed by a wildcard to match everything else.