Download & Extend

Add a hook for modules wanting to add custom JS

Project:Google Analytics
Version:6.x-2.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (duplicate)

Issue Summary

Currently, this module includes textareas for users wanting to add custom JS snippets before and after the JS built by the module itself. However, it doesn't allow other modules a way to plug into this easily. I'd like to propose the addition of a hook so that module can insert JS without having to direct users to put code snippets into these textareas (which is generally bad practice anyways).

Basically, I want to get rid of the UC Google Analytics module we ship with core. If there was a hook here (hook_googleanalytics()?), then I could just use that and not have to worry about making sure hooks are being fired in the proper order so my e-commerce code happens after the base GA code.

I'm happy to spec. this out a little more if you'd like or even provide a patch in the future.

Comments

#1

Ahh, hass posted in the UC issue queue a while back and I didn't realize what the page he linked to was showing. Now I see that it's essentially your recommended way of stuffing code into the variable array on a pageload and making adjustments w/ a regular expression replacement. Honestly, that's pretty tricky and non-standard in the Drupal realm. It's also not foolproof, so I think I'd still want to consider a hook so that the GA module itself can make sure modules don't interfere with one another or have to work through altering the variables array.

#2

Status:active» closed (duplicate)

See #231451: Add hook_google_analytics for other modules.

#3

I waited months to get some feedback but there was no feedback and moshe said we don't need it... however he haven't said why and I'm not sure why... I thought the regex is the way we should go... but not sure. I don't like the regex way very much, too.

#4

Sorry for the duplicate... I seriously don't know how I missed that. : P

nobody click here