Pehea e kākau a hōʻoia ai i nā kānana Regex no Google Analytics (Me nā laʻana)

Nā Hōʻike maʻamau Regex Google Analytics Filters

E like me ka nui o kaʻu mau ʻatikala ma aneʻi, hana wau i kahi noiʻi no kahi mea kūʻai aku a laila kākau e pili ana ma aneʻi. I ka ʻoiaʻiʻo, aia kekahi mau kumu no ke aha ... ʻo ka mea mua he hoʻomanaʻo hoʻomanaʻo weliweli wau a noiʻi pinepine i kaʻu pūnaewele ponoʻī no ka ʻike. ʻO ka lua, ʻo ia ke kōkua i nā poʻe ʻē aʻe e ʻimi paha i ka ʻikepili.

He aha kahi ʻōlelo maʻamau (Regex)?

He ʻano hoʻomohala ʻo Regex e ʻimi a ʻike i kahi lauana o nā huapalapala i loko o ka huaʻōlelo e kūlike a i ʻole hoʻololi i ka ʻōlelo. Kākoʻo nā ʻōlelo ʻōnaehana āpau i nā Manaʻo Hōʻike maʻamau.

Aloha au i nā manaʻo maʻamau (regex) akā hiki iā lākou ke hoʻonāukiuki iki a hoʻonāukiuki paha e aʻo a hoʻāʻo. He mana kupaianaha kā Google analytics ... kahi e hiki ai iā ʻoe ke hana i nā ʻike me nā hiʻohiʻona maʻamau a kānana paha i kāu ʻikepili ma waena o nā hōʻike maʻamau.

ʻO kahi laʻana, inā makemake wau e ʻike i ke kaʻa wale ma kaʻu ʻaoʻao tag, hiki iaʻu ke kānana no / tag / i loko o kaʻu ʻano permalink ma ka hoʻohana ʻana:

/tag\/

Kūhewa ka syntax ma laila. Inā wau e hoʻohana wale i ka "tag", e loaʻa iaʻu nā ʻaoʻao āpau me ka huaʻōlelo i loko o lākou. Inā wau i hoʻohana i ka "/ tag" a laila e hoʻokomo ʻia kekahi URL e hoʻomaka me ka tag, e like me / hoʻokele hoʻokele no ka mea ʻaʻohe paʻamau ʻo Google Analytics i ka hoʻokomo ʻana i kekahi ʻano ma hope o ka hōʻike maʻamau. No laila, pono wau e hōʻoia e loaʻa iaʻu kēia slash i hoʻopili ʻia ... akā pono ia e loaʻa kahi mea pakele ma luna.

ʻaoʻao regex ʻaoʻao

Nā Kumuhana Regex Syntax

Kuhi Description
^ Hoʻomaka me
$ Pau me
. He kāleka wildcard no kekahi ʻano
* ʻO Zero a ʻoi aku paha o ka mea i hala
.* Kūlike me nā huapalapala i
? ʻO Zero a i ʻole hoʻokahi manawa o ka mea i hala
+ Hoʻokahi a ʻoi paha mau manawa o ka mea i hala
| ʻO ka mea lawelawe OR
[abc] A a i ʻole c a i ʻole (hiki i kekahi mau huapalapala)
[az] Laulā o a i z (hiki i kekahi o nā huapalapala)
[AZ] Laulā o A a Z (capitalized)
[0-9] Laulā o 0 a 9 (hiki i kekahi helu)
[a-zA-Z] Ka pae o a i Z a i ʻole Z
[a-zA-Z0-9] Nā huapalapala alphanumeric āpau
{1} 1 kūlike loa (hiki i kekahi helu)
{1-4} Laulā o 1 a 4 mau hanana (hiki i kekahi helu)
{1,} 1 a ʻoi paha nā hanana (hiki i kekahi helu)
() Hoʻohui i kāu mau lula
\ Pakele i nā huapalapala kūikawā
\d Kanaka Digit
\D Kaha helu ʻole
\s Wahi keʻokeʻo
\S Kahi keʻokeʻo ʻole
\w olelo
\W Non-huaʻōlelo (punctuation)

Nā Regex Laʻana No Google Analytics

No laila e kau i kekahi mau laʻana i waho no kekahi Nā kānana Kihi. Ua noi mai kekahi o kaʻu mau hoa iaʻu no ke kōkua e hoʻomaopopo i kahi ʻaoʻao kūloko me ke ala o / papa kuhikuhi me ka hoʻohui i nā pou blog āpau i kākau ʻia me ka makahiki i ka permalink:

ʻO kaʻu kumu kānana maʻamau no ka kahua kānana Noi Url:

^/(index|[0-9]{4}\/)

ʻO ia ka ʻōlelo maʻamau e nānā no / index OR i kēlā me kēia helu helu helu 4 me ka hopena o kahi slash slash. Ua hana wau i kahi ʻike ma Analytics a hoʻohui i kēia ma ke ʻano he kānana:

ʻO Google Analytics View Filter

Eia kekahi mau laʻana hou aʻe:

  • Loaʻa iā ʻoe kahi blog me ka makahiki i ke ala permalink URL a makemake ʻoe e kānana i ka papa inoa i kēlā me kēia makahiki. No laila makemake wau i kekahi helu helu 4 i ukali ʻia e kahi slash slash. Noi i kumu hoʻohālikelike URl:

^/[0-9]{4}\/

  • Makemake ʻoe e hoʻohālikelike i kāu ʻaoʻao āpau kahi o ke poʻo inoa palapala or palapala hoʻomaikaʻi iloko o ia mea. Palapala Kānana poʻo inoa ʻaoʻao:

(.*)certificat(.*)

  • Makemake ʻoe e hoʻohālikelike i ʻelua ʻaoʻao pae e pili ana i kā lākou Campaign Medium i hala i ka URL hōʻeuʻeu Google Analytics as utm_medium = leka uila or uku huli.

(direct\smail|paid\ssearch)

  • Makemake ʻoe e hoʻohālikelike i nā huahana a pau i nā pālule kāne e pili ana i ke ala URL. Noi i kumu hoʻohālikelike URl:

^/mens/shirt/(.*)

  • Makemake ʻoe e hoʻohālikelike i nā ʻaoʻao āpau i helu ʻia ka ala URL e pau me ka helu. Noi i kumu hoʻohālikelike URl:

^/page/[1-9]*/$

  • Makemake ʻoe e kāpae i kahi laulā o nā IP Addresses. E kāpae i ke kumu kānana helu helu IP:

123\.456\.789\.[0-9]

  • Makemake ʻoe e hoʻokomo i kahi ʻaoʻao thankyou.html kahi i kūleʻa ai kahi waiho ʻana ma muli o ka querystring success = ʻoiaʻiʻo. Noi i kumu hoʻohālikelike URl:

thankyou\.html\?success=true

Pehea e hōʻoia ai i kāu Regex Expressions

Ma mua o ka hoʻāʻo a me ka hemahema ma loko o Google Analytics, lele wale wau i luna i regex101, he mea hana kupanaha no ka hoʻāʻo ʻana i kāu mau ʻōlelo maʻamau. Uhaʻi nō ia i kāu syntax nou a hāʻawi i nā kikoʻī o kāu hōʻike maʻamau:

hōʻike manaʻo maʻamau regex101

Kūkulu, hōʻoia, a me Debug Regex

Pehea kou manaʻo?

Ke hoʻohana nei kēia pūnaewele i ka Akismet e ho'ēmi i ka spam. E aʻo pehea e hanaʻia ai kāuʻikeʻikepili.