SEO Reports in Google Analytics 4 (GA4) [2023]

SEO Landing Page Report

Go to Reports > Engagement>Pages and screens

click the pencil icon to customize

Click Dimensions – search and add “Landing page + query string”

Delete other dimensions

Click APply

Click MEtrics

Remove “views”

Add “sessions”

Drag sessions to top.

Click Apply

Click “Add filter” on the right

Search for/add “session default channel group”

Tick “organic”

Click “OK”

Click Save on the top middle-right

Click “Save as new report”

Name is “Landing Pages – Organic” or something

To get the report to appear in the sidebar menu

Click Reports in the left-side bar and then “Library “

Under “life cycle”

click “Edit collection”

Click “Create New Topic”

On the right search for the Landing Page – Organic report

Drag it into the new SEO folder you made (sometimes this doesn’t work as GA4 has a bug at the time of writing)

It worked for me when I dropped it into the second rectangle

Click “back” on the top left

and you should now see an SEO section to the reports.

“SEO Report 2 – Devices or Organic Search Traffic

Go to the Reports>User>Tech >Tech details

Click the Pencil icon to edit the report

Add a filter

Add “session default channel group”

and then Tick “organic” (search for it, if it’s not there for some reason)

Go to Dimensions in the right side bar

Click the 3 dots next to “device category”

Choose “set as default”

Then drag “device category” to the top

Click “Apply”

Click “Save”

Save as a new report

Name it – “Tech details – Organic” or something

  • at the time of writing GA4 is buggy as f*ck, and it won’t let me save this report

Go back

Go to Reports > Library (folder icon near bottom)

Add to the Life Cycle collection

Drag the report into the SEO folder.

SEO Report 3 – Search Engines

Go to Reports>Acquisition>Traffic acquisition

Click the pencil icon to customise the report

Delete on the dimensions in the top right, except for “Session Source”

Click Apply

Add a filter – session default channel group and then select “organic Search”:

Go to reports – click “library” icon at the bottom

Edit the life cycle reports

drag in the new report to the “SEO” section you made for the first report

Google Search Console Reports

Link GA 4 to Search Console

Go to Admin (blue and white cog incon on bottom left of screen)

On the bottom right click “search console links”

Choose the account and web stream and you’re done.

You might need to wait 24 hours for the data to get imported.

Go to Reports > Library (folder icon near bottom)

Life cycle – edit collection

In the top right search for “Google”

You should see 2 reports – Google organic saerch traffic and Queries: organic Google search queries

Click Save – save current collection

SEO Behaviour Exploration Report

Go to “EXPLORE>Path exploration > Start over (top right)

Click the starting point and then select / for homepage

Filter to show organic traffic only

Go to SEGEMENTs (left hand side)

Click the + icon

Click “Session segment”

Click “Add new condition” on the left – add “session default channel group”

Add filter by clicking the box on the right – contains – organic search – click “apply”

Name is “organic search visitors” – “Save and apply”

You can’t add this report to the sidebar (sorry) – so to see it you’ll have to always click into the Explore section.

The Spread Operator in JavaScript (explained in cockney)

TLDR; – The Spread operator allows you to join strings or arrays together in one longer string or array

Image from Reddit

Good tutorial here

Right, guv’nor! Picture this. You’ve got yourself a box of LEGOs, like? Now in the world of JavaScript, this box is what we’d call an array. It’s a list of things, sorted and lined up all proper like.

Now, suppose you have another bigger box, crammed full of all sorts of knick-knacks. You fancy bunging your LEGOs in there, but not as a separate box. Nah, you want to spread ’em out so each LEGO is jumbled up with the other toys.

This is what the JavaScript spread operator is all about. It’s like taking your box of LEGOs and tipping ’em into the larger toy box.

Here’s a little squiz:

let legos = ['red', 'blue', 'green'];
let otherToys = ['doll', 'car', ...legos, 'ball'];

console.log(otherToys); 
// Output: ['doll', 'car', 'red', 'blue', 'green', 'ball']

In this case, ...legos is using the spread operator. It’s like we’re tipping out all the LEGO pieces (each colour) into the otherToys array. Job’s a good ‘un!

So the spread operator ... in JavaScript is like spilling the beans, it pulls all elements from an array (or all properties from an object), and scatters them into something else.

And remember, this operator doesn’t muck about with the original array (or your LEGO box). It’s like taking the LEGO pieces out for a bit of a lark. The original LEGO box is still there, untouched. Bob’s your uncle, Fanny’s your aunt!

Here are some other notes I’ve robbed from other websites (with references back to um tho)

Programiz.com

Spread Operator

The spread operator ... is used to expand or spread an iterable or an array. For example,

const arrValue = [‘My’, ‘name’, ‘is’, ‘Jack’];

console.log(arrValue); // [“My”, “name”, “is”, “Jack”]
console.log(…arrValue); // My name is Jack

In this case, the code:

console.log(...arrValue)

is equivalent to:

console.log('My', 'name', 'is', 'Jack')

Copy Array Using Spread Operator

You can also use the spread syntax ... to copy the items into a single array. For example,

const arr1 = ['one', 'two'];
const arr2 = [...arr1, 'three', 'four', 'five'];

console.log(arr2); 
//  Output:
//  ["one", "two", "three", "four", "five"]

You can run the code in the programiz code runner thing here

codingsumit

Destructing Arrays in JavaScript (2023)

Destructing an array sounds fun, but it’s not.

When we talk about “destructuring” an array, we’re referring to a process where we extract data from arrays, and assign them to variables in a single line. Here’s a basic example:





let array = [1, 2, 3, 4, 5];

// Destructuring the array
let [a, b, c, d, e] = array;

console.log(a); // Output: 1
console.log(b); // Output: 2
console.log(c); // Output: 3
console.log(d); // Output: 4
console.log(e); // Output: 5

In the above code, we’re taking an array of numbers, and using destructuring to assign each number to a variable (a, b, c, d, e).

You can also selectively choose which elements to extract. For example:

let array = ['apple', 'banana', 'cherry', 'dates', 'elderberry'];

// Destructuring the array
let [fruit1, , fruit3] = array;

console.log(fruit1); // Output: apple
console.log(fruit3); // Output: cherry

In this example, we're extracting the first and third elements from the array, while skipping the second element.

"Destructuring" can be particularly useful when you want to quickly access specific data in an array or an object without having to access them using their indexes or keys, respectively.

So, think about breaking the array apart, when you’re thinking about “destructing”

Examples from scaler.com

  • Array Destructuring:




var a, b;
[a, b] = [5, 10];
console.log(a); // 5
console.log(b); // 10
  • Object Destructuring:
({ a, b} = { a: 5, b: 10 });
console.log(a); // 5
console.log(b); // 10

JavaScript Loops – Looping Backwards & Loops in Loops

Notes taken from The Complete JavaScript Course 2023: From Zero to Expert! course on Udemy.

Why would you use a for loop?

I asked Chat GPT this very question, and got this answer:

In JavaScript, a “for” loop is a control flow statement that allows you to execute a block of code a certain number of times. The “for” loop includes initialization, a condition, and incrementation/decrementation.

Here are some reasons and scenarios for using a “for” loop:

  1. Iterating over arrays: You might use a “for” loop when you need to iterate over an array of elements. Each loop iteration corresponds to one element in the array, so you can do something with each individual item.
    Example:
    let arr = [1, 2, 3, 4, 5]; for (let i = 0; i < arr.length; i++) { console.log(arr[i]); // prints each element of the array }
  2. Repetitive tasks: You would use a “for” loop when you need to perform a task a certain number of times. The “for” loop is a straightforward way to repeat a task.

    Example:
    for (let i = 0; i < 10; i++) { console.log(i); // prints numbers 0 to 9 }
  3. Traversing strings: Similar to arrays, you can use a “for” loop to traverse each character in a string.

    Example:
    let str = "Hello, World!"; for (let i = 0; i < str.length; i++) { console.log(str[i]); // prints each character in the string }
  4. Nested loops: You can use “for” loops inside other “for” loops when dealing with multi-dimensional data, such as a matrix or 2D array.
    Example:
    let matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; for (let i = 0; i < matrix.length; i++) { for (let j = 0; j < matrix[i].length; j++) { console.log(matrix[i][j]);
    // prints each element in the matrix } }

Please note that while “for” loops are a classic control flow mechanism, there are other methods in JavaScript for similar use-cases, especially for arrays. This includes methods like Array.prototype.forEach, Array.prototype.map, Array.prototype.filter, and others, which might provide cleaner and more readable code in some scenarios. However, understanding the workings of a “for” loop is fundamental for programming in JavaScript and many other languages.

What are for loops?

Loops, by default, start at the beginning of an array, and work forwards, from variable/element 0 to element 10 – if an array has 10 elements.

Loops can also start at the end, say element 10 and work back to the first element.

for (let i = arrayname.length - 1; i>=0; i--)

In the code above.
The counter called “i” will keep running along as the variable/element is greater than or equal to 0 (the variable number, as in it’s order starting from 0)

Every time the loop runs, instead of adding 1 to “i”, subtract 1.

To print the current element to the console.log, the code should be:

for (let i = arrayname.length - 1; i>=0; i--) {
console.log(jonas[i]);
}

This image from kodify.net explains the parts of a standard for loop quite nicely

for loop

Loop inside a Loop

Loops within loops, are sometimes called “nested loops”.

Image Source

With a nested loop, the outer loop executes first, and the inner loop executes each time the outer loop executes.

If condition 1 is true, then condition 2 will execute.

For a much better explanation, please visit the educba.com website here.

Oh, one more thing that might be useful, I asked Chat GPT to explain for loops like I’m 10 years old:

“Imagine you have a big box of Lego blocks, and you want to look at each block one by one. You would start from the first block, then move to the second, then the third, and so on, until you’ve seen all the blocks. A “for” loop in JavaScript is like doing that – it’s a way for your computer to look at or do something with each item in a list, one at a time, from start to finish.

Here’s a real-life example:

Let’s say you’re on a website that shows all the movies currently playing in theaters. When the website wants to show you all the movie names, it might have a list (in programming, we call this an array) of all those movies. But how does it get from a list of movies to showing each one on your screen? It can use a “for” loop!

In the code of the website, it might look something like this:

let movies = ["Toy Story 4", "The Lion King", "Frozen 2", "Star Wars: The Rise of Skywalker"]; // This is the list of movies.

for (let i = 0; i < movies.length; i++) {
  console.log(movies[i]); // This will show each movie name, one after the other.
}

In this example, i is like a pointer that starts at the beginning of the list (0) and moves one step forward each time the loop runs (i++). The loop keeps going as long as i is less than the length of the list (i < movies.length). And in each loop, movies[i] is how we access each movie name.

This “for” loop helps the website to go through every movie in the list and do something with it – like showing it on your screen!”

Google Analytics 4 Tutorial (GA4 Benefits & Useful Reports) [Updated June 2023]

TLDR;

Useful report 1 – Traffic and Revenue by Channel

Reports – Acquisition – Traffic Acquisition – see channels and revenue – Scroll right to see revenue column in table:

Useful Report 2 – Browser & Device

Reports – User – Tech – Tech details – Add filter for Device:

GA 4 device and browser report

Useful Report 3 – Organic Landing Page Report in GA 4:

Reports – Acquisition – Engagement – Pages and screens –
Add a filter by clicking top right “+” button
Search for “session” and choose session default channel group – exactly matches – Organic search:

Useful Report 4 – Conversion Rate

Check out this post from Analytics Mania

Reports – Life Cycle – Engagement – Pages and SCreens:

GA4 uses events for bloody everything.

You’ll need to set up one type of events – conversions, whilst others are set up for you.

Benefits of GA 4 Include:

  • You can track across app and website
  • Visualise buyer journeys easier
  • Easier to customise reports
  • BigQuery Exports
  • You can ask questions and get quick answers (in the search box at the top)

Things to note:

“bounce rate” in GA4 – is the opposite of engagement rate. So if engagement rate in GA4 is 60%, then bounce rate is 40%

Find Engagement rate in REPORTS > Acquisition > Traffic acquisition

You can add a filter (top left of screen – by the page title) – to filter to specific pages

GA4 Home screen

The home screen gives you a summary or snap shot of your websites performance.

On the top right are real time stats

On the second row, you have recently viewed reports

Below is “insights”, which help you interpret the data

Reports

Reports tab gives a number of prebuilt reports:

Lifecycle Reports

-Acquisition

Where visitors are coming from

-Engagement

What people are doing on the site

-Monetization

What people are buying (on eCommerce sites)

-Demographics and tech

Shows you stuff like visitor age, and what device they are using

EXPLORE SECTION

in this area you can create lots of visuals and insightful reports

ADVERTISING SECTION

purely for Google ads reports

CONFIGURATION SECTION

in the configure section, you can mark events as conversions, create audiences , set up custom dimensions and metrics, and access the debug view to test you’ve implemented stuff correctly.

Useful reports

Traffic sources – where are your visitors coming from, and where are the best visitors coming from

Reports- Acquisition > traffic acquisition

“Engaged traffic” an engaged session = been on your site more than 10 seconds, or visited 2 or more pages or converted

the traffic acquisition report let’s you see how engaged different source s of traffic are. For example, you can compare organic engagement rate vs paid ads.

in the Event Count, and conversions columns, you can click and choose from a dropdown menu which conversions you want to populate the data in the table.

EXPLORE

Explore GA4

A good report to start out with in the explore section, is traffic sources.

Click “Free Form” to start.

On the default table, close the geo column by closing “town/city” on the left side of the screen

Go to DIMENSIONS on the left, click the +

Search for “default channel group” and tick the check box and click “IMPORT”

drag default channel grouping, into the rows area.

Now, for eCommerce, you’ll want to know the value each channel is bringing

On the left side, under VALUES, you’ll want to add transactions (scroll down to see VALUES, it’s below COLUMNS).

EXPLORE > FREE FROM

you can add country and other dimensions to the columns, and see which traffic source from which country (or town or something), drives the most value in terms of purchases or form submissions.

To learn more and isolate a channel, right click and select “include only selected”

for any referral traffic report, you can click the + above DIMENSIONS and search for and select “source”. You can then see which websites are referring the highest quality traffic

click the + icons to search for variables:

PATH EXPLORATION

see how people are journeying through you site

note “screens” is referring to mobile apps

e.g. the pages and screens report, “screens” refers to mobile apps

Useful premade reports:

REPORTING > ENGAGEMENT > PAGES AND SCREENS

“Scrolls” is an event that occurs when a user scrolls past 90% of the page

pretty much everything is an event, so event reports aren’t great. For example, exiting a website is an event.

to make thus report a bit better, we want “engagement rate” added to the table.

  • click the pencil icon in

REPORTS – Snapshot

You can add comparisons, by clicking “Add comparison +” at the top, or by clicking the “edit comparisons” icon which is near the top right:

REAL TIME

Real time reports are from the last 30 minutes (it was 5 mins in GA universal)

You can also add comparisons on realtime reports

ACQUISITION OVERVIEW

These report, show traffic sources that bring visitors to your site

“You can use the User acquisition report to get insights into how new users find your website or app for the first time. The report differs from the Traffic acquisition report, which focuses on where new sessions came from, regardless of whether the user is new or returning.”

source – Google

In the traffic acquisition report, if a user comes from organic search, and then later from paid search, both those sessions will show in the traffic acquisition report, but only organic would should in the User Acquisition report.

ENGAGEMENT

Events – you will see automatic events, like “scroll”, and custom events that you have implemented.

Conversions – “more important events” are conversions – like a purchase. These need to be configured manually.

Pages and Screens – see what people are doing on which pages. “Screens” is a term for mobile apps.

MONETIZATION

Needs sales tracking implemented.

You can see most popular proucts that have sold, how much revenue has been generated etc.

User Retention – Show how many users come back to the site. Don’t trust the data 100% due to cookies being blocked or expiring.

One more thing

You can filter reports by using the search box:

Also – Check out this GA4 course from Analytics Mania

JavaScript Functions and Events (2023)

Notes taken from various websites including:

https://www.w3schools.com/js/js_whereto.asp

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions

JavaScript Functions

A JavaScript function is a block of JavaScript code, that can be executed when “called” for.

For example, a function can be called when an event occurs, like when the user clicks a button.

A function in JavaScript is similar to a procedure—a set of statements that performs a task or calculates a value, but for a procedure to qualify as a function, it should take some input and return an output where there is some obvious relationship between the input and the output.

Source

Function declarations
A function definition (also called a function declaration, or function statement) consists of the function keyword, followed by:

The name of the function.
A list of parameters to the function, enclosed in parentheses and separated by commas.
The JavaScript statements that define the function, enclosed in curly brackets, { /* … */ }.
For example, the following code defines a simple function named square:

function square(number) {
return number * number;
}

The function square takes one parameter, called number. The function consists of one statement that says to return the parameter of the function (that is, number) multiplied by itself. The statement return specifies the value returned by the function:

return number * number;

Parameters are essentially passed to functions by value — so if the code within the body of a function assigns a completely new value to a parameter that was passed to the function, the change is not reflected globally or in the code which called that function.

When you pass an object as a parameter, if the function changes the object’s properties, that change is visible outside the function, as shown in the following example:

function myFunc(theObject) {
theObject.make = “Toyota”;
}

const mycar = {
make: “Honda”,
model: “Accord”,
year: 1998,
};

console.log(mycar.make); // “Honda”
myFunc(mycar);
console.log(mycar.make); // “Toyota”

Differences between functions and methods (taken from Geeks for Geeks)

FunctionMethod
A JavaScript function is a block of code designed to perform a particular task.The javascript method is an object property that has a function value.
Syntax of Function is -:function functionName(parameters) {
   // Content
}
Syntax of Method is -:object = {
   methodName: function() {
       // Content
   }
};object.methodName()
A function can pass the data that is operated and may return the data. The method operates the data contained in a Class.
Data passed to a function is explicit.A method implicitly passes the object on which it was called.
A function lives on its own.A method is a function associated with an object property.
A function can be called directly by its name A method consists of a code that can be called by the name of its object and its method name using dot notation or square bracket notation.
Functions are helpful because it increases the reusability of the code.Javascript includes some in-built methods also for example -: parseInt() Method
The () Operator is used to Invoke the FunctionWe can access object method by the following the syntax -:objectName.methodName()

External JavaScript Advantages

Javascript can also be placed in the <body> of a HTML document and in external sheets with the file extension .js (not sure why I thought this was relevant, but there you go!)
Placing scripts in external files has some advantages:

It separates HTML and code
It makes HTML and JavaScript easier to read and maintain
Cached JavaScript files can speed up page loads

JavaScript Output

ref

JavaScript can interact with the DOM/webpage and display different data in several ways:

  • Wrting into an HTML element using innerHTML
  • Wirting into the HTML output using document.write()
  • Writing into an alert box, using window.alert()
  • Wiring into the browser console, using console.log()

Using InnerHTML

use the document.getElementByID(id) method.

JavaScript Events

HTML events are “things” that happen to HTML elements.

When JavaScript is used in HTML pages, JavaScript can “react” on these events.

more info at w3schools

JavaScript’s interaction with HTML is handled through events that occur when the user or the browser manipulates a page.

When the page loads, it is called an event. When the user clicks a button, that click too is an event. Other examples include events like pressing any key, closing a window, resizing a window, etc.

Developers can use these events to execute JavaScript coded responses, which cause buttons to close windows, messages to be displayed to users, data to be validated, and virtually any other type of response imaginable.

Events are a part of the Document Object Model (DOM) Level 3 and every HTML element contains a set of events which can trigger JavaScript Code.

Please go through this small tutorial for a better understanding HTML Event Reference. Here we will see a few examples to understand a relation between Event and JavaScript −

onclick Event Type

This is the most frequently used event type which occurs when a user clicks the left button of his mouse. You can put your validation, warning etc., against this event type.

Example

Try the following example.

 Live Demo

<html>
   <head>   
      <script type = "text/javascript">
         <!--
            function sayHello() {
               alert("Hello World")
            }
         //-->
      </script>      
   </head>
   
   <body>
      <p>Click the following button and see result</p>      
      <form>
         <input type = "button" onclick = "sayHello()" value = "Say Hello" />
      </form>      
   </body>
</html>

More info at Tutorialspoint (includes a massive list of event types)

The This Keyword in JavaScript (2023)

This – references the object that is executing the current function

  • If the function is part of an object, we call that function a method.

“This” will reference that object

  • if the function is a regular function

“This” will reference the global / window object

in case, like me, you’ve forgotten what an object is, Mozilla describes it as

“In JavaScript, an object is a standalone entity, with properties and type. Compare it with a cup, for example. A cup is an object, with properties. A cup has a color, a design, weight, a material it is made of, etc. The same way, JavaScript objects can have properties, which define their characteristics.”

Example of an Object – with a function/method:

const person = {
  firstName: "John",
  lastName : "Doe",
  id       : 5566,
  fullName : function() {
    return this.firstName + " " + this.lastName;
  }
};

In the example above, this refers to the person object. Because the function is in an object

Some more notes about the This Keyword, robbed from around the web:

In general, the this references the object of which the function is a property. In other words, the this references the object that is currently calling the function.

Javascript Tutorial

Suppose you have an object called counter that has a method next(). When you call the next() method, you can access the this object.

let counter = {
  count: 0,
  next: function () {
    return ++this.count;
  },
};

counter.next();

Inside the next() function, the this references the counter object. See the following method call:

counter.next();

Global context

In the global context, the this references the global object, which is the window object on the web browser or global object on Node.js.

This behavior is consistent in both strict and non-strict modes. Here’s the output on the web browser:

console.log(this === window); // trueCode language: JavaScript (javascript)

If you assign a property to this object in the global context, JavaScript will add the property to the global object as shown in the following example:

this.color= 'Red';
console.log(window.color); // 'Red'

The this keyword is a source of confusion.

If you just type and run “this”, you’ll get the window object (the top of the DOM hierarchy)

If you type “this” inside a function, the value of this is contextual and dynamic. It can change.

Mozilla JS website

In most cases, the value of this is determined by how a function is called (runtime binding). It can’t be set by assignment during execution, and it may be different each time the function is called. The bind() method can set the value of a function’s this regardless of how it’s called, and arrow functions don’t provide their own this binding (it retains the this value of the enclosing lexical context).

In non–strict mode, this is always a reference to an object. In strict mode, it can be any value. For more information on how the value is determined, see the description below.

Description

The value of this depends on in which context it appears: function, class, or global.

Function context

Inside a function, the value of this depends on how the function is called. Think about this as a hidden parameter of a function — just like the parameters declared in the function definition, this is a binding that the language creates for you when the function body is evaluated.

For a typical function, the value of this is the object that the function is accessed on. In other words, if the function call is in the form obj.f(), then this refers to obj. For example:

function getThis() {
  return this;
}

const obj1 = { name: "obj1" };
const obj2 = { name: "obj2" };

obj1.getThis = getThis;
obj2.getThis = getThis;

console.log(obj1.getThis()); // { name: 'obj1', getThis: [Function: getThis] }
console.log(obj2.getThis()); // { name: 'obj2', getThis: [Function: getThis] }

More info and better description of this keyword on the Mozilla website here

Arrow Functions vs Regular Functions in JavaScript (2023)

JavaScript has 2 types of functions.

Normal/regular functions

Arrow functions

Arrow functions are simpler and shorter.

A normal JS function, with arguments (stuff in brackets), which returns something:

function multiply(num1, num2) {
  const result = num1 * num2
  return result
}

The same function, as an arrow function is:

const multiply = (num1, num2) => {
  const result = num1 * num2
  return result
}

If the only statement, is the return statement, then the arrow function can be even shorter:

const multiply = (num1, num2) => num1 * num2

Reference

Freecodecamp


You can define functions in JavaScript by using the “function” keyword.

// Function declaration
function greet(who) {
  return `Hello, ${who}!`;
}

The second way to define a function, is to use the arrow function syntax:

const greet = (who) => {
return Hello, ${who}!;
}


Reference

dmitripavlutin.com


  1. you can omit the return statement and curly braces in arrow function, when its a one line function

2. When the function has only 1 argument, the round bracket is optional.

JavaScript – Primitives Vs Objects

Notes about primitives and objects data types in JavaScript

I’ve got a bit fed up of the Udemy course I’m doing on JavaScript and the videos, so I’m taking notes from different websites and I’ll do a summary at the end.

edureka.co

Primitive Data Types

Primitive data types are number, string, boolean, NULL, Infinity and symbol. Non-primitive data types is the object. The JavaScript arrays and functions are also objects. For more check out this web developer course online.

flaviocopes

Follow Flavio on Twitter

What is the main difference between primitive types and objects in JavaScript?

First, let’s define what are primitive types.

Primitive types in JavaScript are

  • strings
  • numbers (Number and BigInt)
  • booleans (true or false)
  • undefined
  • Symbol values

null is a special primitive type. If you run typeof null you’ll get 'object' back, but it’s actually a primitive type.

Everything that is not a primitive type is an object.

Functions are objects, too. We can set properties and method on functions. typeof will return 'function' but the Function constructor derives from the Object constructor.

The big differences between primitive types and objects are

  • primitive types are immutable, objects only have an immutable reference, but their value can change over time
  • primitive types are passed by value. Objects are passed by reference
  • primitive types are copied by value. Objects are copied by reference
  • primitive types are compared by value. Objects are compared by reference

dev.to

Javascript Types

There are eight data types in Javascript:

  1. string
  2. number
  3. bigint
  4. boolean
  5. undefined
  6. null
  7. symbol
  8. Object

The first 7 of them are commonly called Primitive Types and everything else are Object Types.

Primitive Types

They can only store a single data, have no methods and are immutable. (An immutable value is one whose content cannot be changed without creating an entirely new value. In JavaScript, primitive values are immutable — once a primitive value is created, it cannot be changed, although the variable that holds it may be reassigned another value).

That’s another interesting point! Primitive Types have no methods but, except for null and undefined, they all have object equivalents that wrap the primitive values then we’re able to use methods.

For string primitive there is String object, for number primitive there is Number, and so there are BooleanBigInt and Symbol.

Javascript automatically converts the primitives to their corresponding objects when a method is to be invoked. Javascript wraps the primitive and call the method.

Object Types

Differently from the primitives, Objects can store collections of data, their properties, and are mutable.

Differences between types

1. Assigning to a variable and copying value

The difference in the way the values are stored in variables is what makes people usually call Object Types as Reference Types.

Primitive Types

When we assign a primitive type to a variable, we can think of that variable as containing that primitive value.

let car = "tesla"
let year = 2021

// Variable - Value
// car      - "tesla"
// year     - 2021

So when we assign this variable to another variable, we are copying that value to the new variable. Thus, primitive types are “copied by value”.

let car = "tesla"
let newCar = car

// Variable - Value
// car      - "tesla"
// newCar   - "tesla"

Since we copied the primitive values directly, both variables are separate and if we change one we don’t affect the other.

let car = "tesla"
let newCar = car

car = "audi"

// Variable - Value
// car      - "audi"
// newCar   - "tesla"

Object Types

With Object Types things are different. When we assign an object to a variable, the variable is given a reference to that value. This reference stores the address to the location of that value in memory(techically more than that but let’s simplify). So the variable doesn’t has the value itself.

Let’s imagine the variable, the value it stores, the address in memory and the object in the coming snippets:

let cars = ["tesla"]

// Variable - Value                 - Address - Object
// cars      - <#001> (The reference) - #001    - ["tesla"]

This way, when we assign this variable to another one we are giving it the reference for the object and not copying the object itself like it happens with the primitive value. Thus, objects types are “copied by reference”.

let cars = ["tesla"]
let newCars = cars

// Variable  - Value                 - Address - Object
// cars      - <#001> (The reference) - #001    - ["tesla"]
// newCars   - <#001> (The reference stores the same address)

cars = ["tesla", "audi"]

// Variable  - Value                 - Address - Object
// cars      - <#001> (The reference) - #001    - ["tesla", "audi"]
// newCars   - <#001> (The reference stores the same address)

console.log(cars) // ["tesla", "audi"]
console.log(newCars) // ["tesla", "audi"]

Both of them have references to the same array object. So when we modify the object from one of the variables the other will also have this change.

  • Primitives are ummutable
  • You can’t alter the original primitive, instead it will return a new primitive value
  • Primitives, also have an object counterpart
  • When used with some methods, primitive values get wrapped into an object – once it’s finished, it turns back to a primitive value
  • It does this, because objects can have properties

  • The new keyword creates a blank object, it links the blank object to the parent

Using Get Stat to Monitor Rankings

Home – click on a website to view their rankings

Dashboard Tab

Graph at the bottom is arguably the most helpful.

  • Ranking Averages vs. Distribution Graph
  • If you use the date-picker to a date range of less than 2 weeks, you see daily fluctuations
  • It can be easier to click the # on the bottom left and view the number of KWs in the top 3

Keywords Tab

Click “show/Hide” on top right

Click “google base rank” and “ranking change” and “ranking URL”

Click on the “change” column. Those keywords with a positive change number, have gone down in rankings

Click on each Keyword to see ranking changes over a set date-range (use date-picker on top right)

Competitive Landscape

Compare latest column, to what the share of voice was 7 days ago, 30 days ago, up to 180 days ago.

Click the “site” menu on the top left column of the whole GUI – and pick a category of keywords to see specific changes