You need to use the customTask Builder device to create a customTask
script. customTask
is a technique of the Google Analytics library, which helps you to run JavaScript code when the hit request to Google Analytics is being constructed.
Click on right here to leap on to the device.
That is very helpful for a lot of causes, and I like to recommend you learn customTask
– The Information earlier than doing something with the device.
The device robotically builds the required JavaScript, avoiding any potential conflicts that the overlapping strategies may introduce in any other case.
While you add particular person options to the script by choosing objects within the desk, you’ll see how the ultimate script is modified accordingly.
When you find yourself happy with the consequence, choose all of the textual content throughout the white code field. You may also click on the Copy to clipboard button to robotically copy the code to your clipboard.
Basic deployment directions
Upon including particular person objects to the script, you’ll discover that the primary strains of the script comprise default values that you just’ll want to switch. For instance, when including the Shopper ID as a Customized Dimension merchandise, you’ll see these strains added to the code:
// clientIdIndex: The Customized Dimension index to the place you need to ship the customer's Shopper ID.
// https://bit.ly/2Ms0ZcC
var clientIdIndex = 1;
The worth 1
is only a default worth – you’ll want to alter this to the Customized Dimension index you might have created in Google Analytics for this particular objective.
Thus after copy-pasting the code into place, be sure to edit all of the default values with the precise values you need to configure the objects with. In any other case you’ll run into extreme knowledge high quality points.
Deployment with Google Tag Supervisor
In case you are utilizing Google Tag Supervisor, it’s good to copy-paste the code right into a Customized JavaScript variable. When you use the “Copy to clipboard (for GTM)” button, you don’t have to switch the JavaScript as instructed under.
If, for some cause, you refuse to make use of the “Copy to clipboard (for GTM)” button, after copy-pasting the contents to the Customized JavaScript variable, you’ll want to switch the primary line by eradicating the var _customTask =
half like this:
// OLD, CHANGE THIS:
var _customTask = perform() {
// NEW, TO THIS:
perform() {
The second change it’s good to do is take away the semi-colon on the very finish of the code block. In different phrases, take away the final character of all the code block, which ought to be a semi-colon ;
.
When you’re achieved modifying the default values, save the variable with the identify {{customTask}} or one thing related and descriptive.
Then, in your Google Analytics Settings variable, go to Fields to set, and add a brand new area:
Area identify: customTask
Worth: {{customTask}}
When you’re not utilizing a Google Analytics Settings variable, it’s good to click on Allow overriding settings on this tag in all of the Google Analytics tags the place you need to add this customTask
as a area, and make the identical change on to the tag itself.
Deployment with analytics.js
With the common (legacy) Common Analytics library, you first want to verify the variable is written into reminiscence, so within the web site JavaScript (or web page template), ensure that the code within the code field under is executed earlier than any Google Analytics instructions are run.
Then, whenever you need to invoke this customTask
in your trackers, discover the place you’re creating the tracker and make the next change:
ga('create', 'UA-12345-1');
ga('set', 'customTask', _customTask()); // <-- Add this proper after creating the tracker
ga('ship', 'pageview');
Click on to pick which function(s) to incorporate |
---|
Shopper ID as a Customized Dimension |
Hit Sort as a Customized Dimension |
Payload Size as a Customized Dimension |
Take away Customized Definitions from Web page Pace Timing Hits |
Copy Hits to A number of Properties |
Take away PII from Hits |
Copy Hits to Snowplow Collector Endpoint |
Replace Session Cookie |
Enhance Cross-domain Iframes |
Forestall Duplicate Transactions |
Obfuscate And Copy Hit Payload |
Use localStorage To Persist Shopper ID |
|
Abstract
I hope you discover this device helpful. I'll attempt to replace it as I give you new customTask
concepts, which appears to be very often.
Please let me know within the feedback if you're having hassle utilizing the device, or if in case you have new customTask
concepts in thoughts you’d need to embrace within the device.