Custom variables are now split into custom dimensions and custom metrics. This allows more flexibility, and you get an increased number of each (currently 20 of each totaling 40, up from 5 for the free version).
Sets the custom variable to your specifications. In analytics.js, you need to decide if your custom
variable is a metric or a dimension (more on this).
Once this is done, you'll need to set it up within the interface
before you can use it. Both custom variables and custom metrics / dimensions need to be sent with or before an event.
It should be noted that we actually call it 2 different ways in the analytics.js examples below.
The first example uses the "set" method. This allows all of the following "send" events
(pageview, social, events, etc.) to utilize the dimensions and metrics until the visitor visits the next
page or until the tracker object expires. The second example passes it within the "send" event itself.
This makes those dimensions and metrics available to only that one send call. This is important to
consider and will vary depending on what you're sending in. Below, we have made the appropriate choice
to send in the image information with the image upload event as it only pertained to that image and would
not be useful to any other calls on the page, unlike the information about the visitor in the first example.
Now let's see what it looks like when you're pushing the dimensions & metrics in via a send command…