Guys,

it would be a fantastic feature if this module integrates with ecommerce to track all itens and transactions.
im going to work on this. and help is welcome.

regards,

massa

Comments

budda’s picture

Status: Active » Closed (won't fix)
brmassa’s picture

Status: Closed (won't fix) » Active

Mike,

A ecommerce tracker should not be in the GA core. it can be a new extra module inside GA project. Ecommerce users and normal users will have the optimized system.

A second option is to create a new project just for a small piece of code. I believe its a waste.

regards,

massa

budda’s picture

Its been a while since I've used the ecommerce package. Does something need to be done at their end to expose the cart items on the transaction success page?

Any thoughts on how best to implement it?
Maybe hook_nodeapi() could be used to inject the javascript into the success page?

brmassa’s picture

Mike,

i have a good experience with programming ecommerce module. i created 3 modules related and i oftem help them on patches. its going to need a little intervention on their code, i think. im trying to imagine a way to less invasive, maybe using, yes, nodeapi or form_alter hooks.

cheers,

massa

brmassa’s picture

Mike,

im in a very good progress with integration. im gonna start a testing phase.
note i require the modifications on the code shown on other issues.

regards,

massa

brmassa’s picture

Status: Active » Needs review
StatusFileSize
new10.08 KB

Guys!

i did it! after some days testing, the ecommerce integration is there! its pretty simple in fact. I did several tests and its capturing transactions fine. I also changed the readme file to warn that the transaction ID from google analytics will not be the same Transaction ID from Drupal/Ecommerce. The reason is the TxnID to GA should be created before the TxnID created by Drupal. GA needs only a unique number, so the module uses a combination of time() and cart_get_id() functions. it works like a breeze.

As long it requires the patchs i did on http://drupal.org/node/134422 and http://drupal.org/node/101509, im gonna post a patch to cover all these. JavaScripts as well. I changed the install file to perform all needed changes on database.

It requires jquery, so its only useful for Drupal 5. I think its possible to port to 4.7.

best regards,

massa

brmassa’s picture

StatusFileSize
new782 bytes

Now the javascript.

I recommend to use a JavaScript compressor (http://dean.edwards.name/packer) and keep a original version as ga_developer.js or something like this. Since its a small script, it wont get much smaller, but every help is a help.

(rename to googleanalytics.js)

gordon’s picture

I have taken a quick look at this, and it seems that it records with Analytics no matter what the outcome of the order is.

Shouldn't it only record completed transactions.

brmassa’s picture

Gordon,

you are right! i forgot to post here a modification i wrote on my testing site:
1* textarea is now, of course, hidden.
2* __utmSetTrans(), the function that tell google about the transaction, is called when the "place the order" button is pressed only instead on the page load.

these changes seems to work fine here. i will publish the mod soon.

regards,

massa

brmassa’s picture

Gordon,

one thing should be considered: there is no perfect solution about this tracking, coz GA uses javascript. if you click on "place the order" and some validation fails, GA will consider it as done.

i thought about recording a session variable and only when the page reloads (the "thanks for purchasing with us" page), the transaction would be recorded. but some payment systems delete the session variables to avoid stealing credit card numbers and private data.

GA overwrites data when the transaction id was used before, so might have a good solution here.

for now, the best solution is: submit button having a "onclick:__utmSetTrans();" attribute.

regards,

massa

brmassa’s picture

StatusFileSize
new10.29 KB

Guys,

as promissed, the new patch. Mike, i suggest to commit to dev at least. many users will be needed to test it.

i wont submit the new javascript > the only line changed from last update is the removal of the last line.

regards,

massa

erlendstromsvik’s picture

Hi

I've taken this module and made it compatible with Ubercart so to provide Google Analytics E-commerce tracking.

But wouldn't it be better if the "original" Google Analytics module invoked a hook, which E-Commerce, Ubercart and/or any other commerce-package could implement to insert the needed code for e-commerce tracking?
The only thing need in this module is a _hook-call and just append any output to the $script variable in uc_googleanalytics_footer(). For example hook_googleanalytics()?

I don't see an option in using hook_footer to just append the extra code for e-commerce tracking because this code must be inserted after the tracker code.

budda’s picture

Why can your Ubercart module not just define the GA JS variable in the pages header as inline JavaScript? It doesn't need to be after the Google Analytics function code in the footer as you are just defining a variable to describe the transaction contents.

To make it neater only output the inline JavaScript if the GoogleAnalytics module is installed/activated.

No hooks required then.

johnalbin’s picture

Status: Needs review » Needs work

Hi Bruno,

It’s a bad idea to include fixes for several issues in one patch.

  • It’s difficult to tell what code is fixing what issue.
  • It makes it really difficult for people tracking a single, small issue to review a big patch.
  • It’s difficult to mark a big patch as RTBC because people have to be familiar with all the issues.
  • And if you introduce a bug with this patch, it’s impossible to quickly rollback the patch without breaking all the issues again.

Please break up your patch into several smaller patches and post them to the appropriate issues. Thanks!

brmassa’s picture

John,

i know about patches, its because i did it all at once and i dont have time/energy to do it on the right way.
its not that big patch, its possible to study it.
but.. if someone slipt it, fine.

regards,

massa

ps: I already use it on my site.

johnalbin’s picture

Bruno, without a proper patch your work is unlikely to be committed and you’ll have to re-write your customized-GA module each time the code base changes; it’s a waste of your time to write a patch that has no chance of being committed. It’s ultimately easier for you (and less time consuming in the long run) to provide proper patches from the beginning.

budda’s picture

Status: Needs work » Postponed (maintainer needs more info)

Is my suggestion in comment #13 a possible solution to this for uber and ec? or am i barking up the wrong tree here?

hass’s picture

Subscribing, i think #13 sounds like a good idea, but does not prevent duplicate variable names - what might cause some side effects in special situations.

hass’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

No activity / feedback for more then one month - closing as the maintainers think it doesn't need to be fixed by the GA module them self.