Use customTask and Universal Analytics

Business Benefits

Add value to Universal Analytics tracking on the website.


Use customTask Builder to send the same GA hit to multiple Google Analytics properties, like Roll-Up and Local properties, without having to duplicate tags.

  1. Select Copy Hits to Multiple Properties in customTask Builder.
  2. Copy the code and paste it into a new Custom JavaScript variable created in Google Tag Manager.
  3. Add the Universal Analytics tracking IDs where you want to send the duplicated payload to the duplicateHitToTrackingIds array and save the variable.
  4. Add this variable to the tag you want to duplicate under Fields to Set using the field name customTask and the value set to the variable you just created.

Select Remove PII from Hits in customTask Builder to clear personally identifiable information from the entire Google Analytics payload.

  1. Copy the code and paste it into a Custom JavaScript variable created in Google Tag Manager.
  2. Add new objects as instructed in the copy-pasted code to the piiRegEx array, each with a name describing the redaction and a regular expression containing the pattern to redact. The example preloaded into the copy-pasted code includes a simple email address pattern check.
  3. Add the variable you created above to the tag whose data you want to redact under Fields to Set using the field name customTask and the value set to the variable you just created.

Select Client ID as a Custom Dimension and Hit Type as a Custom Dimension in customTask Builder to enrich Google Analytics hits with useful metadata from the Google Analytics tracker.

  1. Copy the generated code and paste it into a Custom JavaScript variable.
  2. Set the custom dimension indices to their respective variables (clientIdIndex, hitTypeIndex) as instructed in the copy-pasted code.
  3. Add the Custom JavaScript variable to the tag whose data you want to enrich under Fields to Set using the field name customTask and the value {{your customTask variable}}.

Select Prevent Duplicate Transactions in customTask Builder to prevent Universal Analytics collecting duplicate transactions.

  1. Copy the generated code and paste it into a Custom JavaScript variable.
  2. Configure the cookie name and expiration in the transactionDeduper variable.
  3. Add this variable to the Enhanced Ecommerce Purchase tag under Fields to Set using the field name customTask and the value {{your customTask variable}}.

Select Update Session Cookie in customTask Builder to create a session cookie in the browser to mimic the session length calculated by Universal Analytics.

  1. Copy the generated code and paste it into a Custom JavaScript variable.
  2. Update expiration (30 minutes by default) and domain name to write the cookie on.
  3. Add this variable to your Universal Analytics tags under Fields to Set using the field name customTask and the value {{your customTask variable}}.

Use a Google Analytics Settings Variables to share a customTask across your Google Analytics tags.

  1. Navigate to Variables > New > Variable Configuration in Google Analytics and create a Settings variable.
  2. Add a new field using named customTask under Fields to Set and set the value to the customTask variable you want to share across the tags.
  3. Add the Google Analytics Settings variable to the Google Analytics tags you want to share customTask with.

Use customTask Builder to combine multiple customTasks into one.

  1. Create a new Custom JavaScript variable in Google Tag Manager to use as your customTask variable.
  2. Open customTask Builder and select all the customTasks you want to combine.
  3. Copy the resulting code and paste it into the Custom JavaScript variable you created in Google Tag Manager

Only a single customTask field can be set in any tag (or Google Analytics Settings variable). So, it’s important to use the Builder to combine all the different customTasks you want to set into a single code block.