Add hook to alter data before sending it to browser

Created on 7 March 2008, almost 17 years ago
Updated 6 July 2023, over 1 year ago

Problem/Motivation

Reusable/swapable tracking code with rendering/theming logic.

Proposed resolution

API to allow other modules to alter/extend the tracking code.

Remaining tasks

Write tests for the Google Analytics Test module (see tests/modules/google_analytics_test).

User interface changes

None

API changes

  • hook_google_analytics_tracker_alter()

Original report by @username

Since ga.js it looks impossible (untested) for other modules to set a custom variable in head. So it becomes impossible to add tracking data like shopping data to the ga tracking. See http://0-code.google.com.millennium.unicatt.it/apis/analytics/docs/gaJSA... for some good examples.

var pageTracker = _gat._getTracker("UA-12345-1");
   pageTracker._initData();
   pageTracker._trackPageview();
   pageTracker._addTrans(
      "1234", // order ID - required
      "Womens Apparel", // affiliation or store name
      "11.99", // total - required
      "1.29", // tax
      "15.00", // shipping
      "San Jose", // city
      "California", // state or province
      "USA" // country
    );
   pageTracker._addItem(
      "1234", // order ID - required
      "DD44", // SKU/code
      "T-Shirt", // product name
      "Olive Medium", // category or variation
      "11.99", // unit price - required
      "1" // quantity - required
   );
   pageTracker._trackTrans();

It looks like we need a hook or something else that would allow other modules to set custom variables and urls. We should do some brainstroming what the best way would be.

✨ Feature request
Status

Closed: outdated

Version

2.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States japerry KVUO

    With the sunset of legacy google analytics, the 8.x-2.x module is now unsupported. If this is still an issue with the 4.x version, please file a new issue in the queue.

Production build 0.71.5 2024