diff --git omniture.js omniture.js new file mode 100644 index 0000000..5c70a97 --- /dev/null +++ omniture.js @@ -0,0 +1,68 @@ +/* + * Make a call to omniture from js + * PARAM params: on object to merge into the s object to pass vales + * PARAM clean_obj: a bool, if true will remove default vars before sending + */ +function omniture_t(params, clean_obj) { + if (typeof( variable ) == 'undefined' ) { + clean_obj = true; + } + var sObj; + if (clean_obj) { + sObj = s_gi(s_account); + _omniture_clean(sObj) + } + else { + sObj = s_gi(s_account); + } + sObj = $.extend(sObj, params); + sObj.t(this); +} + +/* + * Make a link call to omniture from js + * PARAM params: on object to merge into the s object to pass values + * PARAM type: the type of link 'o', 'd', 'e' to pass to the link function + * PARAM value: the value to pass to the link function + * PARAM clean_obj: a bool, if true will remove default vars before sending + */ +function omniture_tl(params, type, value, clean_obj) { + if (typeof( variable ) == 'undefined' ) { + clean_obj = false; + } + var sObj; + if (clean_obj) { + sObj = s_gi(s_account); + _omniture_clean(sObj) + } + else { + sObj = s_gi(s_account); + } + // List all param keys as tracked vars + trackvars= [] + sObj = $.extend(sObj, params); + $.each(params, function(k,v) { + trackvars.push(k) + }) + sObj.linkTrackVars=trackvars.toString() + sObj.linkTrackEvents= params.events + + sObj.tl(this, type, value); +} +/* + * a helper function to remove values from the s object + */ +function _omniture_clean(sObj) { + for(var i = 0; i < 100; i++) { + sObj['prop' + i] = ''; + sObj['eVar' + i] = ''; + } + sObj.products = ''; + sObj.events= ''; + sObj.linkTrackVars = ''; + sObj.server = ''; + sObj.channel = ''; + sObj.pageName = ''; + sObj.pageType = ''; + sObj.campaign = ''; +} diff --git omniture.module omniture.module index 2a6bc3a..8078bb3 100644 --- omniture.module +++ omniture.module @@ -42,6 +42,13 @@ function omniture_menu() { } /** + * Implementation of hook_init() + */ +function omniture_init() { + drupal_add_js(drupal_get_path("module", "omniture"). "/omniture.js", "module"); +} + +/** * Implementation of hook_footer() to insert Javascript at the end of the page */ function omniture_footer($main = 0) {