/red/modules/tracking/omniture.tracking.js

http://github.com/ff0000/rosy · JavaScript · 94 lines · 56 code · 27 blank · 11 comment · 8 complexity · 1de9b28177e5954603ab0ade299e3600 MD5 · raw file

  1. // ### Part of the [Rosy Framework](http://github.com/ff0000/rosy)
  2. /* omniture.tracking.js */
  3. // ## Local Namespace
  4. var red = red || {};
  5. red.module = red.module || {};
  6. red.module.tracking = red.module.tracking || {};
  7. /**
  8. * Omniture and GA tracking event wrappers
  9. * REQUIRES
  10. - ssla-analytics/ (this file loads ssla-analytics/analytics.min.js)
  11. */
  12. (function () {
  13. red.module.tracking.Omniture = (function () {
  14. return red.Module.extend({
  15. _tracker : null,
  16. vars : {
  17. debug : true, // set to false for production
  18. media_url : null //defaults to <link rel="media-url"' content="{{STATIC_URL}}" />
  19. },
  20. log : function () {
  21. if (this.vars.debug) {
  22. try {
  23. console.log(arguments);
  24. } catch (e) {}
  25. }
  26. },
  27. init : function () {
  28. this.loadJSDK();
  29. $.subscribe("track", $.proxy(this.track, this));
  30. },
  31. track : function (e, data) {
  32. this.log("o track is not setup yet =(", data.type, data);
  33. },
  34. onReady : function () {
  35. var i,
  36. account;
  37. this.tracker = new window.ssla.analytics.Omniture({}, window.s); // pass in an optional Library object
  38. if (this.vars.accounts) { // set account relationships passed in init()
  39. for (i = this.vars.accounts.length - 1; i >= 0; i--) {
  40. account = this.vars.accounts[i];
  41. window.ssla.analytics.Omniture.addAccount(account[0], account[1]);
  42. }
  43. }
  44. },
  45. loadJSDK : function () {
  46. this.vars.media_url = this.vars.media_url || $('link[rel="media-url"]').attr("href");
  47. if (!this.vars.media_url) {
  48. throw "tracking:Omniture missing MEDIA_URL";
  49. }
  50. Modernizr.load([{
  51. load : [
  52. this.vars.media_url + "js/red/modules/tracking/ssla-analytics/analytics.min.js"
  53. /*this.vars.media_url + "js/red/modules/tracking/ssla-analytics/source/analytics.js",
  54. this.vars.media_url + "js/red/modules/tracking/ssla-analytics/source/s_code.js"*/
  55. ],
  56. complete : $.proxy(this.onReady, this)
  57. }]);
  58. },
  59. destroy : function () {
  60. $.unsubscribe("track", $.proxy(this.track, this));
  61. this.tracker = null;
  62. this.vars = null;
  63. }
  64. });
  65. }.call(red.module.tracking));
  66. }());