Yuav Sau Ntawv li cas thiab Kuaj Li Cas Rau Regex Lim Rau Google Analytics (Nrog Piv Txwv)

Cov Lus Qhia Zov Siv Regex Google Analytics Lim

Raws li nrog ntau ntawm kuv cov lus ntawm no, Kuv ua qee qhov kev tshawb fawb rau tus neeg siv khoom thiab tom qab ntawd sau txog nws ntawm no. Yuav tsis ncaj ncees, muaj ob peb lub laj thawj vim li cas… ua ntej tshaj yog tias kuv muaj qhov cim xeeb tsis zoo thiab feem ntau tshawb nrhiav kuv tus kheej lub vev xaib rau cov ntaub ntawv. Qhov thib ob yog pab lwm tus neeg uas tseem yuav tshawb nrhiav cov ntaub ntawv.

Kev Nyuaj Li Cas (Regex)?

Regex yog ib txoj kev txhim kho los tshawb thiab txheeb xyuas tus qauv ntawm cov cim hauv cov ntawv sau rau sib phim lossis hloov cov ntawv sau. Txhua hom lus niaj hnub programming txhawb kev nthuav qhia Kev Hais Lus.

Kuv nyiam kev qhia (rov rex) tab sis lawv tuaj yeem ua me ntsis lossis ua kev npau taws rau kawm thiab sim. Google analytics muaj qee cov peev xwm zoo kawg nkaus ... qhov uas koj tuaj yeem tsim kev pom nrog cov kev hais tawm tsis tu ncua lossis lim koj cov ntaub ntawv hauv cov kab lus ib txwm muaj

Piv txwv li, yog tias kuv xav pom kom tsuas yog kev ua lag luam ntawm kuv cov nplooj ntawv sau tag, Kuv tuaj yeem lim rau / tag / hauv kuv tus qauv permalink los ntawm kev siv:

/tag\/

Lub syntax yog qhov tseem ceeb nyob rau ntawd. Yog tias kuv nyuam qhuav siv “tag”, Kuv yuav tau txais txhua nplooj ntawv nrog kab lus cim nyob hauv lawv. Yog tias kuv siv "/ tag" ces txhua URL pib lub cim npe yuav raug suav nrog / tag-tswj vim tias Google Analytics vim li cas suav nrog ib lub cim tom qab qhov kev hais tawm tas li. Yog li, Kuv xav tau los xyuas kom meej tias kuv muaj cov kab laum hauv qab no suav nrog ... tab sis nws yuav tsum muaj ib lub cim khiav tawm ntawm nws.

nplooj ntawv lim regex

Regex Syntax Lub hauv paus

syntax Hauj lwm
^ Pib nrog
$ Xaus nrog
. Ib tug tsiaj ntawv me rau cov xeeb ceem
* Xoom lossis ntau dua ntawm cov khoom dhau los
.* Qhov twg hauv cov zauv
? Xoom lossis ib lub sijhawm ntawm cov khoom dhau los
+ Ib lossis ntau lub sijhawm ntawm cov khoom dhau los
| LOSSIS tus neeg teb xov tooj
[abc] A lossis b lossis c (tuaj yeem yog cov lej ntawm lub cim)
[az] Ntau yam ntawm a txog z (tuaj yeem yog tus naj npawb ntawm cov cim)
[AZ] Ntau yam ntawm A txog Z (siv nyiaj loj)
[0-9] Ntau ntawm 0 txog 9 (tuaj yeem yog ib tus naj npawb)
[a-zA-Z] Qhov ntau ntawm a txog Z lossis A txog Z
[a-zA-Z0-9] Txhua tus tsiaj ntawv alphanumeric
{1. Raws nraim 1 Piv txwv (tuaj yeem yog tus lej)
{1-4}. Ntau thaj tsam li 1 txog 4 zaus (tuaj yeem yog ib tus naj npawb)
{1,} 1 lossis ntau zaus (tuaj yeem yog ib tus naj npawb)
() Pawg koj cov cai
\ Tso cov cim tshwj xeeb tseg
\d Xob tus yam ntxwv
\D Tsis-tus lej
\s Dawb chaw
\S Cov chaw tsis-dawb
\w lo lus
\W Tsis-lo lus (cim)

Regex Piv Txwv Rau Google Analytics

Yog li cia peb muab ib co piv txwv tawm rau qee qhov Cov Ntxaij Lim Dej NchuavCov. Ib qho ntawm kuv cov npoj yaig tau thov kuv rau kev pabcuam txhawm rau txheeb xyuas sab hauv sab hauv nrog txoj kev ntawm / qhia ntsuas ntxiv rau txhua qhov blog uas tau sau nrog lub xyoo hauv lub permalink:

Kuv cov kev cai lim rau lub lim teb Thov Url:

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

Qhov tseeb ntawd hais qhia / saib lossis cim rau 4-tug lej muaj txoj hauv kev xaus nrog cov kab txiav ncaj. Kuv tsim kev pom rau hauv Analytics thiab ntxiv qhov no raws li lub lim:

Google Analytics Pom Lim

Ntawm no yog ob peb yam piv txwv ntxiv:

  • Koj muaj blog nrog lub xyoo nyob hauv kab URL permalink thiab koj xav tau lim cov npe rau ib xyoos. Yog li kuv xav muaj 4 tus lej tom qab los ntawm kev sib tsoo luv. Thov URl Lim Txawv:

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

  • Koj xav piv tag nrho koj cov nplooj ntawv uas lub npe muaj daim ntawv pov thawj or certification nyob rau hauv nws. Nplooj Ntawv Lim Lim Txawv:

(.*)certificat(.*)

  • Koj xav muab piv ob daim ntawv tsaws raws nplooj ntawv raws li lawv Kev Sib Tham Qhov Nruab Nrab hla hauv Google Analytics kev sib tw URL li utm_medium = xa ncaj qha or them nyiaj tshawb.

(direct\smail|paid\ssearch)

  • Koj xav sib piv tag nrho cov khoom uas yog txiv neej lub tsho raws li txoj kev URL. Thov URl Lim Txawv:

^/mens/shirt/(.*)

  • Koj xav piv tag nrho cov nplooj ntawv suav txoj kab URL uas xaus nrog tus lej. Thov URl Lim Txawv:

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

  • Koj xav tau cais tawm ntau ntawm IP Chaw. Tsis suav IP Chaw Nyob Lim Qauv:

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

  • Koj xav kom suav nrog nplooj ntawv thankyou.html qhov kev xa tawm tau ua tiav raws li kev nug kev nug = qhov tseeb. Thov URl Lim Txawv:

thankyou\.html\?success=true

Yuav Kuaj Koj Li Cas Regex Expressions

Dua li qhov kev sim thiab qhov yuam kev tsis pub dhau Google Analytics, Kuv feem ntau tsuas yog dhia rau rov 101, ib qho khoom siv zoo heev rau kuaj koj cov lus qhia tas li. Nws tseem txhawm rau koj syntax rau koj thiab muab cov ntsiab lus ntawm koj qhov kev qhia tsis tu ncua:

cov kab lus ib txwm regex101

Tsim, Ntsuas, thiab Debug Regex

Yuav ua li cas koj xav hais tias?

Qhov Web site no siv Akismet los txo cov kev pabcuam. Kawm li cas koj cov ntaub ntawv tawm tswv yim tiav.