Event tracking using Google Tag Manager · Log into Google Tag Manager · Select “Tags” from the left-hand side · Create a new tag and select ...
twitter
linkedin2
facebook
youtube
instagram
search
star
viewallservices
GoogleAnalyticsEventtrackingisausefulfeaturethatallowsyoutorecordinteractionswithelementsofyourwebsitewhicharen'ttrackedasstandardwithinGoogleAnalytics.
GoogleAnalyticsEventtrackingisaninvaluablefeaturethatallowsyoutorecordinteractionswithelementsofyourwebsitewhicharen’ttrackedbydefaultwithinGoogleAnalytics.
Simplybyaddingsnippetsofcodetoyoursite,itispossibletotrackeventinteractionstounderstandhowlongusersspendwatchingyourvideosorevenwhichfieldsonyourformsusersdropoffat.
Inthispost,IexplainhowtotrackeventsmanuallybyeditingthecodeonyoursiteorbyusingGoogleTagManagerifyouarelessconfidentwitheditingcode.
YoucansetupeventtrackingmanuallyoneachlinkoruseGoogleTagManagerto automateyoureventtracking.
WhatcanGoogleAnalyticseventtrackingbeusedfor?
Beforewegointodetailabouthowtoseteverythingup.Let’slookatsomeofthedifferentwaysthatEventtrackingcanbeusedtomeasurevisitorengagementonyoursite.Someofthetypicalusesforeventtrackingarelistedbelow:
Trackingoutboundlinkclickstootherwebsites.
Understandinghowmanyusersclickedonmailtoemailaddressesorclick-to-callphonenumbers.Thiscanhelpyoutobetterunderstandthenumberofenquiriesyouaregettingfromyoursite.
TrackingPDFandothermediadownloads.
Measuringinteractionswithvideocontent,suchastimespentwatchingavideo.
Trackingexactlywhereusersdropoffwhenfillinginfieldsonyourformsorcheckout
Monitoringtheclicksonuniqueelementsofapage,suchasthe“contactus”calltoactiononyouraboutpage.
Collectingdataabouthowmanyusersfilledinandsubmittedaform,althoughIwouldalwaysrecommendsendinguserstothankyoupageswheneverpossible.
Eventtrackingallowsyoutocountinteractionsthatdon’tnecessarilyinvolveloadinganotherpageonyourwebsite.GoogleAnalyticsgoalscanalsobesetupbasedonyourevents.
GoogleAnalyticsEventTrackinginGoogleAnalytics–Examplesoftrackedeventcategories
Whattoconsiderbeforeyoustart
TouseeventtrackingyouwillneedtohaveGoogleAnalyticsinstalledonyourwebsite.ThiscanbeachievedbyaddingthecodetoallofthepagesonyoursiteorbyaddingGoogleTagManagercodetoyoursiteandthenconfiguringGoogleAnalyticstagsandtriggersandvariables.
Beforeyoujumpintosettingupeventtracking,itisimportanttoconsiderthefollowingpoints:
TherearetwoversionsofGoogleAnalyticstrackingcode.CheckwhetheryouareusertheolderUniversalGoogleAnalytics(Analytics.js)codeorthenewerGoogleAnalyticsgtagcode(gtag.js)beforeapplyinganycodereferencedinthispost.IrecommendmigratingtothenewerversionofGoogleAnalyticsandGooglehaswrittenaguideonhowtomigratetousinggtag.js.asthisdesignedtocombatintelligenttrackingprevention(ITP)thatblockscookiedatainbrowsers.
Decideon whichelementsofyoursiteyouwanttotrack,whetheritisPDFdownloadsorclicksonoutboundlinks.
Adoptaconsistentandclearnamingconventionforthedifferentaction,labelandcategoryoptionsavailabletoyouwhenyouaresettingupeventtracking.Everynameyougivetoeachcategory,actions,andlabelsappearsintheeventtrackingreports.Ifyournamingisn’tsensiblethenyourreportwon’tmakealotofsenselateron.
Decidewhetheryouwanttosetupauto-eventtaggingormanuallytaglinksonyoursite. Ifyouhavealotofdocumentsandpageelementstotrackitmaybeworthsettingup AutoEventTaggingandusingGoogleTagManagerEvents.
HowdoesGoogleAnalyticseventtrackingwork?
Asnippetofcustomcodeisaddedtothelinkcodeontheitemsyouwanttotrackonyourwebsiteandwhentheitemisclicked,theelementistrackedanddisplayedasaneventinGoogleAnalytics.
Theeventtrackingcodeconsistsoffourelementsthatyoucandefinetodescribeauser’sinteractionon yourwebsite:
Category(Required)isthenameyougivetoagroupofobjectsyouwanttotrack.
Action(Required)isthetypeofinteraction,suchasdownloadingadocument.
Label(Optional)isusefulforsummarisingwhattheeventisabout,suchasclicksonnavigationmenuoptions.
Value(Optional)canbeusedifyou’dliketoassignanumericvaluetoyourfiledownload.
Whentheeventfiresonyoursite,the‘Category’,‘Action’,‘Label’and‘Value’attributescanbeusedtohelpyouunderstandexactlywhattheuserengagedwithonyourpage.Asmentionedabove,itisimportanttogivesomethoughttothenamingconventionsusedfortheseattributesasthesevaluesarewhatwillshowwithinGoogleAnalytics.
TheeventtrackingcodeforaneventtrackedlinkinUniversalAnalyticslookslikethis:
onclick=”ga(‘send’,‘event’,‘Category’,‘Action’,‘Label’,‘Value’);”
Thecodeisplaced afterthehreflinktextasillustratedintheexamplebelow:
Thecategory,action,labelandvaluelabelsarereplacedbythevaluesthatyoudecidetoenter.Anexampleofaneventtrackedlinkwithenteredvaluesisfurtherdownthepage.
HowtosetupGoogleAnalyticseventTracking
Dependingonthenumberofeventsyouwouldliketotrack,or thelevelofcontrolyouwouldliketohaveonthetrackingparametersforyourevents,youcansetupupautoeventtracking,ormanuallytaglinksonyourwebsite.
Ifyouhavelotsofdocumentsandpageelementstotrack itisworthusingautoeventtagging.ThiscanbedoneusingGoogleTagManager.Autoeventtaggingwillfireonthefollowing:
Whenusersclickonlinks.
Clicksonanytypeofpageelement.
Afteracertainvisitdurationorattimedintervals.
Onsubmissionofaform.
IfthereareotheractionsthatyouwouldliketotrackyoucanuseGoogleTagmanagertosetthisup.
Manuallytagginglinkstotrackevents
Youcanmanuallycustomiselinksonyoursitetoaddthe ‘Category’,‘Action’,‘Label’,‘Value’attributestoalinkasalreadydiscussedearlier. Togiveyouapracticalexampleofthis,theexamplebelowshowsalinkthatincludeseventcodefortrackingaPDFdownload.
TheitalicisedtextbelowshowsanexampleofeventtrackingparametersconfiguredtorecordthedownloadofacompanybrochurePDFdocument.
DownloadOurBrochure
Auto-eventtrackingoptions
EventtrackingusingGoogleTagManager
Youcanmeasureinteractionsonyoursitebysettingup GoogleTagManager’sAuto-EventTracking.
Thismightsoundcomplicatedbutonceyouunderstandthebasicprinciplesoftags,triggersandvariablesitbecomesquitestraightforward.
EventtrackingusingGoogleTagManagerisinitiatedviaclicksoneventtriggersthatcanbesetuponspecificvariablesonyourwebpage.GoogleTagManagerEventsareuseractionswithwebpageelements(“DOMelements”)thataretriggeredbyyourbrowserandsentintotheTagManagerdatalayersothattheycanbeusedtosetuptriggers.
AsummaryofthestepsrequiredtosetupaneventwithinGoogleTagManagerarelistedbelow:
LogintoGoogleTagManager
Select“Tags”fromtheleft-handside
Createanewtag andselect UniversalAnalyticsastheTagType
SetyourGoogleAnalyticsTrackingID
Choose“Event”forthetracktype
SetyourEventCategory,Action,LabelandValues.YoucanuseGoogleTagManagervariablenamessuchas {{clickurl}}
Setyourtriggersasrequired
AnexampleofhowtosetupaneventwithinGoogleTagManagerisoutlinedbelow:
Step1–checkyouhavetherightenabledvariablesselectedforyourevent
HeadovertotheVariablessectioninGoogleTagManagerandmakesurethatyouhavetickedthevariablesthatyouwouldliketotrackonyoursite.
Youhavetheoptiontosetupyourtriggersbasedonclickclasses,clickelements,clicktextandothervariables.
Step2–createanewtaginGoogleTagManager
CreateanewtaginGoogleTagManagerandchangetheTrackTypeto‘Event’.TheconfigurationoptionswillnowincludetrackingparameterfieldsforCategory,Action,LabelandValueasshowninthescreenshotbelow.
Aswediscussedearlierinthispost,theCategory,Action,LabelandValueattributesformthebasisoftheeventvariableswithinGoogleAnalytics.ThereareGoogleTagManagerspecificcodevariablesthatyoucanusetoautomaticallypopulatefieldswithvalues.Forexample,the{{Click}}codewillautomaticallypullinthewebURLintothefielditisenteredinto.
Step3–configurethetag
Entervaluesfor Category,Action,LabelandValue.
Thelabelshouldreallybe namedtogiveyouasmuchinformationaspossibleonwhatwasclicked.Ifyouwereplanningtotrackclicksonthenavigationbuttonsinyoursiteheader,youmaywanttorecordtheclickURLoftheitemthatwasclickedon.
TheValueboxforyoureventcanbepopulatedifyouwanttoattributeanominalvaluetotypesofenquiriesonyoursite.Youmaywanttogiveacontactformsubmissionahighervaluethananemailnewslettersignupforexample.
TheTrue/Falsefieldisusedforanon-interactionevent.Ifyouwantyoureventactionnottocreateanewpageviewandnottoimpactonthebounce-rate,thensetthisvaluetoTrue.
Settingthetagforatrackedeventisthesameeverytime.Themaindifferenceinsettingupdifferenttypesoftagsiswillbeinconfiguringwhatthetagfireson.
Step4–selectwhattheeventtagwillfireon
Thenextstepistoselectorcreateatriggerforthetagtofireon.Youwillneedtosetthefireonconditionsforyourtag.Ihaveincludedafewexamplesofthedifferenttypesoftriggersfordifferenteventsonyoursite.
Triggerformeasuringclicksonanemailaddresslink
Anexampleofacompletedtriggerforanemailaddressclickedlinkisbelow.
OnthechooseTriggerTypescreenundertheClickheadingchooseJustLinks
SelecttheSomeLinkClicksunderthistriggerfireson
SetthevariabletoClickURLwithinthefirstdrop-downbox
SpecifythattheURL‘Contains’intheseconddrop-downoption
Entermailto:withinthethirdfield
Triggerformeasuringclicksonaphonenumber
OnthechooseTriggerTypescreenundertheClickheadingchooseJustLinks
SelecttheSomeLinkClicksunderthistriggerfireson
SetthevariabletoClickURLwithinthefirstdrop-downbox
SpecifythattheURL‘Contains’intheseconddrop-downoption
Entertel:withinthethirdfield
TriggerformeasuringPDFdownloads
UsingGTMtosetupaPDFdownloadevent
OnthechooseTriggerTypescreenundertheClickheadingchooseJustLinks
SelecttheSomeLinkClicksunderthistriggerfireson
SetthevariabletoClickURLwithinthefirstdrop-downbox
SpecifythattheURL‘Contains’intheseconddrop-downoption
Enter.pdf withinthethirdfield
Testingthatyoureventsworkasplanned.
Itisagoodideatocheckthatyoureventsworkasyouintend.ToviewresultsimmediatelyyoucanpreviewyourGoogleTagManagereventsusingthepreviewfeatureandcarryoutyoureventactiontoseewhetherthetagfiressuccessfully.
WithinGoogleAnalyticsyoucanalsoseeeventsfiredwithinthelast30minutesbygoingtotheReal-TimesectionandthenEventssection.
Ifyou’renotinarushorwanttoviewhistoricdata,gototheBehaviour>EventssectionofGoogleAnalytics.
SettingUpEvent-BasedGoals
GoalscanalsobesetupinGoogleAnalyticsbasedonyourevents.TodothislogintoyourGoogleAnalyticsaccountandfollowtheseinstructions:
Gotothepropertywhereyouwanttosetupthegoal
ClickonAdminandthengotoGoalsandclickonAddNewGoal
Giveyourgoalanameandselecttheeventgoalradiobuttonoption
Fillinthefieldswiththeattributesforyourspecificgoal.RemembertoselectEqualto,BeginswithorRegularExpressionoptionsbasedonyoureventattributes.
Category
Action
Label
Value
SaveyourGoal
Remembertocompleteatestgoalsothatyouhavedataandthencomebackthenextdaytocheckyoureventgoalworks
Screenshotshowinghowtocreateanevent-basedgoalinGoogleAnalytics
Conclusion
GoogleAnalyticsEventTrackingisavaluableadditiontomeasuringuserinteractionsonyourwebsite.ItcanbeusedincombinationwithtraditionalGoogleAnalyticsgoalstomeasuremicroormacroconversionsonyoursite.UsingGoogleTagManagerandTagManagereventsmeansitisnoweasierforyoutosetupandcontroltheeventsyouwanttotrackoryoucanstillchangethecodeonyoursitemanuallytoaddeventsifyouprefer.
Usefullinks
Google’sEventTrackingGuideforUniversalGoogleAnalytics.js
OnlineUniversalAnalyticseventtrackingcodebuilder
Outboundlinkeventtracking
Haveyoujustlearnedsomethingnew?
Thenjointhe80,000peoplewhoreadourexpertarticleseverymonth.
Firstname*Lastname*Emailaddress*
BysigninguptothisformIagree,thatHallammaystoremydataandmaycontactmeusingtheemailaddressIhaveprovidedwithpromotionalemailsaboutproducts,specialoffers,andotherinformationwhichmaybeofinterest.Pleasealsoreadourprivacypolicy.YoucanrevokeyourconsentatanytimeCAPTCHAEmailThisfieldisforvalidationpurposesandshouldbeleftunchanged.
Δ
Ifyouneedhelpwithyour GoogleAnalytics
don'thesitateto contactus.
Enjoythisarticle?
Subscribeforweeklyinsights
Youmayalsolike
BenWood
UTMCodes:HowtoTrackCampaignURLsinGoogleAnalytics
TeamHallam
FormeventtrackingwithGoogleTagManager
Jonathan'Cat'Catton
10TopTipsforusingGoogleAnalytics
UsingGoogleAnalyticseventtracking
Share
×
Sharethis
LinkURLCopied
Let’sthrivetogether
Getintouchtotakethefirststep.
Contactus
Haveyoujustlearnedsomethingnew?
Thenjointhe80,000peoplewhoreadourexpertarticleseverymonth.
Firstname*Lastname*Emailaddress*
BysigninguptothisformIagree,thatHallammaystoremydataandmaycontactmeusingtheemailaddressIhaveprovidedwithpromotionalemailsaboutproducts,specialoffers,andotherinformationwhichmaybeofinterest.Pleasealsoreadourprivacypolicy.YoucanrevokeyourconsentatanytimeCAPTCHANameThisfieldisforvalidationpurposesandshouldbeleftunchanged.
Δ
×
Weusecookiestounderstandhowyouinteractwithourwebsite.Butwe’llonlysetthemifyouchoosetoaccept.Ifyou’dratherwedidn’t,youcanchangeyourpreferencesthrough'Mysettings'.AcceptMysettingsManageconsent
Close
PrivacyOverview
Thiswebsiteusescookiestoimproveyourexperiencewhileyounavigatethroughthewebsite.Outofthese,thecookiesthatarecategorizedasnecessaryarestoredonyourbrowserastheyareessentialfortheworkingofbasicfunctionalitiesofthewebsite.Wealsousethird-partycookiesthathelpusanalyzeandunderstandhowyouusethiswebsite.Thesecookieswillbestoredinyourbrowseronlywithyourconsent.Youalsohavetheoptiontoopt-outofthesecookies.Butoptingoutofsomeofthesecookiesmayaffectyourbrowsingexperience.
Essential
Essential
AlwaysEnabled
Essentialcookiesareabsolutelynecessaryforthewebsitetofunctionproperly.Thesecookiesensurebasicfunctionalitiesandsecurityfeaturesofthewebsite,anonymously.
CookieDurationDescriptioncf_use_ob1yearThiscookieissetbytheproviderCloudflarecontentdeliverynetwork.Thiscookieisusedfordeterminingwhetheritshouldcontinueserving"AlwaysOnline"untilthecookieexpires.cookielawinfo-checbox-analytics11monthsThiscookieissetbyGDPRCookieConsentplugin.Thecookieisusedtostoretheuserconsentforthecookiesinthecategory"Analytics".cookielawinfo-checbox-functional11monthsThecookieissetbyGDPRcookieconsenttorecordtheuserconsentforthecookiesinthecategory"Functional".cookielawinfo-checbox-others11monthsThiscookieissetbyGDPRCookieConsentplugin.Thecookieisusedtostoretheuserconsentforthecookiesinthecategory"Other.cookielawinfo-checkbox-necessary11monthsThiscookieissetbyGDPRCookieConsentplugin.Thecookiesisusedtostoretheuserconsentforthecookiesinthecategory"Necessary".cookielawinfo-checkbox-performance11monthsThiscookieissetbyGDPRCookieConsentplugin.Thecookieisusedtostoretheuserconsentforthecookiesinthecategory"Performance".PHPSESSIDsessionThiscookieisnativetoPHPapplications.Thecookieisusedtostoreandidentifyausers''uniquesessionIDforthepurposeofmanagingusersessiononthewebsite.Thecookieisasessioncookiesandisdeletedwhenallthebrowserwindowsareclosed.viewed_cookie_policy11monthsThecookieissetbytheGDPRCookieConsentpluginandisusedtostorewhetherornotuserhasconsentedtotheuseofcookies.Itdoesnotstoreanypersonaldata.
Performance
performance
Performancecookiesareusedtounderstandandanalyzethekeyperformanceindexesofthewebsitewhichhelpsindeliveringabetteruserexperienceforthevisitors.
CookieDurationDescription_ga2yearsThiscookieisinstalledbyGoogleAnalytics.Thecookieisusedtocalculatevisitor,session,campaigndataandkeeptrackofsiteusageforthesite''sanalyticsreport.Thecookiesstoreinformationanonymouslyandassignarandomlygeneratednumbertoidentifyuniquevisitors._gat1minuteThiscookiesisinstalledbyGoogleUniversalAnalyticstothrottletherequestratetolimitthecolllectionofdataonhightrafficsites._gid1dayThiscookieisinstalledbyGoogleAnalytics.Thecookieisusedtostoreinformationofhowvisitorsuseawebsiteandhelpsincreatingananalyticsreportofhowthewebsiteisdoing.Thedatacollectedincludingthenumbervisitors,thesourcewheretheyhavecomefrom,andthepagesvistedinananonymousform.
Non-Essential
non-necessary
Anycookiesthatmaynotbeparticularlynecessaryforthewebsitetofunctionandisusedspecificallytocollectuserpersonaldataviaanalytics,ads,otherembeddedcontentsaretermedasnon-necessarycookies.Itismandatorytoprocureuserconsentpriortorunningthesecookiesonyourwebsite.
CookieDurationDescription__hssc30minutesThiscookieissetbyHubSpot.Thepurposeofthecookieistokeeptrackofsessions.ThisisusedtodetermineifHubSpotshouldincrementthesessionnumberandtimestampsinthe__hstccookie.Itcontainsthedomain,viewCount(incrementseachpageViewinasession),andsessionstarttimestamp.__hssrcsessionThiscookieissetbyHubspot.Accordingtotheirdocumentation,wheneverHubSpotchangesthesessioncookie,thiscookieisalsosettodetermineifthevisitorhasrestartedtheirbrowser.IfthiscookiedoesnotexistwhenHubSpotmanagescookies,itisconsideredanewsession.__hstc1year24daysThiscookieissetbyHubspotandisusedfortrackingvisitors.Itcontainsthedomain,utk,initialtimestamp(firstvisit),lasttimestamp(lastvisit),currenttimestamp(thisvisit),andsessionnumber(incrementsforeachsubsequentsession)._gh_sess1yearThiscookieisusedtopreserveusersstatesacrosspagerequests._lfa2yearsThiscookieissetbytheproviderLeadfeeder.ThiscookieisusedforidentifyingtheIPaddressofdevicesvisitingthewebsite.ThecookiecollectsinformationsuchasIPaddresses,timespentonwebsiteandpagerequestsforthevisits.ThiscollectedinformationisusedforretargetingofmultipleusersroutingfromthesameIPaddress.AnalyticsSyncHistory1monthNodescriptionANONCHK10minutesThiscookieisusedforstoringthesessionIDforauser.ThiscookieensuresthatclicksfromadvertisementontheBingsearchengineareverifiedanditisusedforreportingpurposesandforpersonalization.bcookie2yearsThiscookieissetbylinkedIn.ThepurposeofthecookieistoenableLinkedInfunctionalitiesonthepage.bscookie2yearsThiscookieisabrowserIDcookiesetbyLinkedshareButtonsandadtags.hubspotutk1year24daysThiscookieisusedbyHubSpottokeeptrackofthevisitorstothewebsite.ThiscookieispassedtoHubspotonformsubmissionandusedwhendeduplicatingcontacts.IDE1year24daysUsedbyGoogleDoubleClickandstoresinformationabouthowtheuserusesthewebsiteandanyotheradvertisementbeforevisitingthewebsite.Thisisusedtopresentuserswithadsthatarerelevanttothemaccordingtotheuserprofile.langsessionThiscookieisusedtostorethelanguagepreferencesofausertoserveupcontentinthatstoredlanguagethenexttimeuservisitthewebsite.language1yearThiscookieisusedtostorethelanguagepreferenceoftheuser.li_gc2yearsThiscookieissetbyLinkedInlidc1dayThiscookieissetbyLinkedInandusedforrouting.MUID1year24daysUsedbyMicrosoftasauniqueidentifier.ThecookieissetbyembeddedMicrosoftscripts.ThepurposeofthiscookieistosynchronizetheIDacrossmanydifferentMicrosoftdomainstoenableusertracking.NID6monthsThiscookieisusedtoaprofilebasedonuser''sinterestanddisplaypersonalizedadstotheusers.UserMatchHistory1monthLinkedin-Usedtotrackvisitorsonmultiplewebsites,inordertopresentrelevantadvertisementbasedonthevisitor''spreferences.VISITOR_INFO1_LIVE5months27daysThiscookieissetbyYoutube.UsedtotracktheinformationoftheembeddedYouTubevideosonawebsite.vuid2yearsThisdomainofthiscookieisownedbyVimeo.Thiscookieisusedbyvimeotocollecttrackinginformation.ItsetsauniqueIDtoembedvideostothewebsite.YSCsessionThiscookiesissetbyYoutubeandisusedtotracktheviewsofembeddedvideos.
Save&Accept