AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

Analytics
4.8K members online now
4.8K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

Event Tracking using Javascript

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi,

Currently we use Javascript to post events to GA.

We are interested in knowing how the visitor came to the website so we manually set campaign source, campaign name , content, medium by looking at the URL query string and extracting utm and gclid stuff. Hence, all these tracking parameters are sent to GA with the event.

I was told by a colleague that if we only send the client id along with the event, that should be enough and GA itself will figure out source, medium, keywords, etc.

Is that correct?

Can some please share some knowledge?

 

Event Tracking using Javascript

Explorer ✭ ✭ ☆
# 2
Explorer ✭ ✭ ☆

Could you please provide an example? All hits to Google Analytics are always sent via the GA javascript library (analytics.js) and you shouldn't have to do any customisations at all to tracke traffic sources.

 

Event Tracking using Javascript

Explorer ✭ ✭ ✭
# 3
Explorer ✭ ✭ ✭

Hey Sofia,


Google analytics by default track the source / medium of the user who comes to your site.
Here is how you can learn a bit mire a about google analytics traffic source tracking
https://support.google.com/analytics/answer/6205762?hl=en

 

hit like if this help

kind regards

Noman Karim

Event Tracking using Javascript

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭

Hi Philip,

Thanks for your response.

We post events to GA based on some event triggered by the website visitor.

 

Here is part of our code, just to give you an idea. Let me know if you would like to see more:

 

 

ga('create', 'UA-XXXXXXXX-1', 'auto');
:

:

:
if(k == 'utm_source'){
ga('set', 'campaignSource', v);
}
if(k == 'utm_medium'){
ga('set', 'campaignMedium', v);
}
if(k == 'utm_term'){
ga('set', 'campaignTerm', v);
}
if(k == 'utm_campaign'){
ga('set', 'campaignName', v);
}

ga('send', 'pageview');
ga('send', 'event', 'Chat', 'Conversion', 'Email Received');