Problem/Motivation

Universal Analytics has stopped supporting Custom Variables in favor of Custom Dimensions and Metrics:
https://developers.google.com/analytics/devguides/collection/analyticsjs...

Proposed resolution

The 2.x branch must convert the current Custom Variables interface and integration code to match the new API.

I don't think there's a clean update path from ga.js to analytics.js, though. Not only do Dimensions and Metrics need to be pre-configured within Google's management interface, which may cause slots to change, but there's also no way to programmatically decide whether a particular Custom Variable should be converted to a Dimension or a Metric.

Remaining tasks

#231451: Add hook to alter data before sending it to browser

User interface changes

None

API changes

Hm... yes.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Les Lim’s picture

Status: Active » Needs review
FileSize
14.81 KB

The following patch updates both the admin interface and the integration code in hook_page_alter().

hass’s picture

Thanks a lot for sharing this patch. It looks like we need to support up to 200 dimensions. :-(

I thought about adding a local tab to the admin ui and add an interface like manage fields to allow these high number...

hass’s picture

Issue summary: View changes
Status: Needs review » Postponed

This is blocked by #231451: Add hook to alter data before sending it to browser and requires a rerole for this one.

bmarshall’s picture

Just wanted to check to see if there was an ETA to get custom dimensions & metrics implemented? Working on a project that's been usually this module for a while now, but needs dimensions support ASAP in order to get the reporting they need.

hass’s picture

May I ask if you are able to sponsor the coding?

bmarshall’s picture

Would love to, but I'm fairly new to Drupal and not naive enough to call myself a Drupal developer yet.

In order to get it working for the needs of the project I'm on, it appears the patch in #1 works. All I had to do was uncomment the code that adds the custom dimensions/metrics script in googleanalytics.module on line 314. Viewed the source and tested with the GA debugger extension and all looks good.

Other than that, the only thing left I think would be to allow for 200 dimensions. Don't think there's a need to create a script to move the old custom variables into dimensions due to having to first set them up in GA.

hass’s picture

You can donate.

boldart’s picture

@hass - I am also interested in getting Custom Dimensions completed and am interested in donating towards that end. What would help and how would I go about it?

hass’s picture

Status: Postponed » Active

I'm not blocking this on the other case any longer.

wiifm’s picture

Status: Active » Needs review
FileSize
15.13 KB

Attached is a patch that simply enables the output of the custom dimensions and metrics (as for some reason this was commented out). Everything else is the same.

Can confirm it works as expected, and that tokens are being replaced.

Not too sure about having 20 dimensions in the admin UI (I am using only 2), might be nicer as a follow up issue to use AJAX to add another row to the form (ala adding choices to polls).

hass’s picture

Version: 7.x-2.x-dev » 8.x-2.x-dev
hass’s picture

Assigned: Unassigned »
hass’s picture

Version: 8.x-2.x-dev » 7.x-2.x-dev
FileSize
28.89 KB

a

Status: Needs review » Needs work

The last submitted patch, 13: Issue-2136031-Implement-custom-dimensions-and-metric.patch, failed testing.

hass’s picture

Status: Needs work » Needs review
FileSize
28.9 KB
  • Cast metric values to float
  • Removed the length limit for custom vars. I have not found any documentation about this and this limit may has been removed. If not we can add back, later.
  • Added tests
  • Added uninstall
  • Changed Slot to Index to follow Googles wording
  • Added readme changes.
  • Trim values before saving them.

  • hass committed c39cb6f on 7.x-2.x
    Issue #2136031: Implement custom dimensions and metrics
    

  • hass committed 4c52a48 on 8.x-2.x
    Issue #2136031: Implement custom dimensions and custom metrics
    
hass’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.