samedi 2 décembre 2017

Google Analytics - Tracking parameters

I have an assignment that involves javascript and Google Analytics, which I am not familiar with yet. I was wondering if anyone would be able to help me to understand that, please see below:

Question #1: Describe what the following code block does when executed in a browser

function formatQs() { var output = {}; var qs = document.location.search.substring(1); qs = qs.split('&'); for (var i = 0; i < qs.length; i++) { var tokens = qs[i].split('='); output[tokens[0].toLowerCase()] = tokens[1]; } return output; }

What I've done so far (just some random notes about the code above): {} empty array where the characters will be loaded into

string looks like this at the end of the url from my last google search ?q=postgresql+open+database&rlz=1C1CHBF_deIE769IE769&oq=postgresql+open+database&aqs=chrome..69i57j0l5.4497j0j7&sourceid=chrome&ie=UTF-8

split this string on every "&" (separates the tracking parameters in the URL) and store the split stuff in a temporary array variable "qs"

every single element in qs will be split again on the character "="

then you make a two dimensional array out of the variable output, put the thing before = as key and the thing after = as value

My question: I don't understand actually what "executed in a browser" means, is it adding the code to Dev tools in Chrome > Console > Enter?

Question #2: Describe a specific scenario in which the above function would be used for tracking purposes, and more specifically how Google Analytics uses the data to track marketing campaigns.

What I've done so far: In Google Analytics, Marketing campaigns can be tracked using UTM parameters, which are tags added to the end of an URL, to track the traffic coming from different channels. For example, to track what particular post, tweet, page or link the user clicked on to finds your website. You can track these visitors by campaign under Google Analytics > Acquisition section.

I'm not sure if that's exactly what this questions is about, as I didn't understand Question 1.

Any advice of where I should be researching, and if I started this right or not would be appreciated. Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire