| 1 |
<?php |
<?php |
| 2 |
// $Id: omniture.module,v 1.4 2008/10/03 02:33:16 ultimateboy Exp $ |
// $Id: omniture.module,v 1.5 2008/10/06 22:22:52 ultimateboy Exp $ |
| 3 |
/* |
/* |
| 4 |
* @file |
* @file |
| 5 |
* Drupal Module: Omniture SiteCatalyst Stats |
* Drupal Module: Omniture SiteCatalyst Stats |
| 6 |
* Adds the required Javascript to the bottom of all your Drupal pages |
* Adds the required Javascript to the bottom of all your Drupal pages |
| 7 |
* to allow tracking by the Omniture statistics package. |
* to allow tracking by the Omniture SiteCatalyst statistics package. |
| 8 |
* Based on the Google Analytics package by Mike Carter |
* Based on the Google Analytics package by Mike Carter |
| 9 |
* |
* |
| 10 |
* @author: Greg Knaddison |
* @author: Greg Knaddison |
| 23 |
return array('administer SiteCatalyst configuration'); |
return array('administer SiteCatalyst configuration'); |
| 24 |
} |
} |
| 25 |
|
|
|
|
|
| 26 |
/** |
/** |
| 27 |
* Implementation of hook_menu |
* Implementation of hook_menu |
| 28 |
*/ |
*/ |
| 38 |
'type' => MENU_NORMAL_ITEM, |
'type' => MENU_NORMAL_ITEM, |
| 39 |
); |
); |
| 40 |
|
|
|
|
|
| 41 |
return $items; |
return $items; |
| 42 |
} |
} |
| 43 |
|
|
| 56 |
} |
} |
| 57 |
|
|
| 58 |
// Don't track page views in the admin sections, or for certain roles |
// Don't track page views in the admin sections, or for certain roles |
| 59 |
if (arg(0) != 'admin' && $track > 0 && !$match) { |
if (arg(0) != 'admin' && $track > 0) { |
| 60 |
|
|
|
|
|
|
// If they have created an inc file, include it and run it |
|
|
$path = drupal_get_path('module', 'omniture'); |
|
|
if (is_file($path .'/omniture.inc')) { |
|
|
require_once($path .'/omniture.inc'); |
|
|
|
|
|
if (function_exists('omniture_variables')) { |
|
|
// Call the specific logic and loop through it to output it |
|
|
$omniture_inc_vars = omniture_variables(':'); |
|
|
} |
|
|
} |
|
|
|
|
| 61 |
// Add any custom code snippets if specified |
// Add any custom code snippets if specified |
| 62 |
$codesnippet = variable_get('omniture_codesnippet', ''); |
$codesnippet = variable_get('omniture_codesnippet', ''); |
| 63 |
|
|
| 78 |
else { |
else { |
| 79 |
$terms_for_omniture .= $taxonomy->name; |
$terms_for_omniture .= $taxonomy->name; |
| 80 |
} |
} |
|
|
|
| 81 |
} |
} |
| 82 |
} |
} |
| 83 |
if (isset($terms_for_omniture)) { |
if (isset($terms_for_omniture)) { |
| 86 |
} |
} |
| 87 |
} |
} |
| 88 |
} |
} |
|
|
|
|
|
|
| 89 |
} |
} |
| 90 |
|
|
| 91 |
// Format and combine variables in the "right" order |
// Format and combine variables in the "right" order |
| 92 |
// Right order is the code file (least likely to be maintained) |
// Right order is the code file (least likely to be maintained) |
| 93 |
// Then admin settings with codesnippet first and finally taxonomy->vars |
// Then admin settings with codesnippet first and finally taxonomy->vars |
| 94 |
$extra_variables_formatted = ""; |
$extra_variables_formatted = $codesnippet; |
|
if (isset($omniture_inc_vars)) { |
|
|
foreach ($omniture_inc_vars as $variable => $value) { |
|
|
$extra_variables_formatted .= "\n". $variable .'="'. $value .'";'; |
|
|
} |
|
|
} |
|
|
$extra_variables_formatted .= $codesnippet; |
|
| 95 |
|
|
| 96 |
if (isset($omniture_vocab_vars)) { |
if (isset($omniture_vocab_vars)) { |
| 97 |
foreach ($omniture_vocab_vars as $variable => $value) { |
foreach ($omniture_vocab_vars as $variable => $value) { |
| 99 |
} |
} |
| 100 |
} |
} |
| 101 |
|
|
| 102 |
$script = "<!-- SiteCatalyst code version: H.13.\nCopyright 1997-2007 Omniture, Inc. More info available at\nhttp://www.omniture.com -->"; |
$header = "<!-- SiteCatalyst code version: H.13. Copyright 1997-2007 Omniture, Inc. More info available at http://www.omniture.com -->\n"; |
| 103 |
$script .= '<script type="text/javascript" language="JavaScript" src="'; |
$header .= "<script type=\"text/javascript\" language=\"JavaScript\" src=\""; |
| 104 |
$script .= check_plain(variable_get("omniture_js_file_location", 'http://www.example.com/js/s_code_remote_h.js')); |
$header .= check_plain(variable_get("omniture_js_file_location", 'http://www.example.com/js/s_code_remote_h.js')); |
| 105 |
$script .= '"></script>'; |
$header .= "\"></script>\n"; |
| 106 |
$script .= '<script type="text/javascript" language="JavaScript"><!--'."\n"; |
$header .= "<script type=\"text/javascript\" language=\"JavaScript\"><!--\n"; |
| 107 |
$script .= '/* You may give each page an identifying name, server, and channel on'."\n"; |
|
| 108 |
$script .= 'the next lines. */'."\n"; |
$footer = '/************* DO NOT ALTER ANYTHING BELOW THIS LINE ! **************/'."\n"; |
| 109 |
$script .= 's.pageName=""'."\n"; |
$footer .= 'var s_code=s.t();if(s_code)document.write(s_code)//--></script>'."\n"; |
| 110 |
$script .= 's.server=""'."\n"; |
$footer .= '<script language="JavaScript" type="text/javascript"><!--'."\n"; |
| 111 |
$script .= 's.channel=""'."\n"; |
$footer .= "if(navigator.appVersion.indexOf('MSIE')>=0)document.write(unescape('%3C')+'\!-'+'-')"."\n"; |
| 112 |
$script .= 's.pageType=""'."\n"; |
$footer .= '//--></script><noscript><a href="http://www.omniture.com" title="Web Analytics"><img src="'; |
| 113 |
$script .= 's.prop1=""'."\n"; |
$footer .= check_plain(variable_get("omniture_image_file_location", 'http://examplecom.112.2O7.net/b/ss/examplecom/1/H.13--NS/0')) .'"'."\n"; |
| 114 |
$script .= 's.prop2=""'."\n"; |
$footer .= 'height="1" width="1" border="0" alt="" /></a></noscript><!--/DO NOT REMOVE/-->'."\n"; |
| 115 |
$script .= 's.prop3=""'."\n"; |
$footer .= '<!-- End SiteCatalyst code version: H.13. -->'."\n"; |
| 116 |
$script .= 's.prop4=""'."\n"; |
|
| 117 |
$script .= 's.prop5=""'."\n"; |
if ($omniture_hooked_vars = module_invoke_all('omniture_variables', $main)) { |
| 118 |
$script .= '/* Conversion Variables */'."\n"; |
if (isset($omniture_hooked_vars['header'])) { |
| 119 |
$script .= 's.campaign=""'."\n"; |
$header = $omniture_hooked_vars['header']; |
| 120 |
$script .= 's.state=""'."\n"; |
} |
| 121 |
$script .= 's.zip=""'."\n"; |
if (isset($omniture_hooked_vars['variables'])) { |
| 122 |
$script .= 's.events=""'."\n"; |
foreach ($omniture_hooked_vars['variables'] as $k => $v) { |
| 123 |
$script .= 's.products=""'."\n"; |
$extra_variables_formatted .= "$k=\"$v\";\n"; |
| 124 |
$script .= 's.purchaseID=""'."\n"; |
} |
| 125 |
$script .= 's.eVar1=""'."\n"; |
} |
| 126 |
$script .= 's.eVar2=""'."\n"; |
if (isset($omniture_hooked_vars['footer'])) { |
| 127 |
$script .= 's.eVar3=""'."\n"; |
$footer = $omniture_hooked_vars['footer']; |
| 128 |
$script .= 's.eVar4=""'."\n"; |
} |
| 129 |
$script .= 's.eVar5=""'."\n"; |
} |
| 130 |
|
|
| 131 |
|
$script = $header; |
| 132 |
$script .= $extra_variables_formatted; |
$script .= $extra_variables_formatted; |
| 133 |
$script .= '/************* DO NOT ALTER ANYTHING BELOW THIS LINE ! **************/'."\n"; |
$script .= $footer; |
| 134 |
$script .= 'var s_code=s.t();if(s_code)document.write(s_code)//--></script>'."\n"; |
|
|
$script .= '<script language="JavaScript" type="text/javascript"><!--'."\n"; |
|
|
$script .= "if(navigator.appVersion.indexOf('MSIE')>=0)document.write(unescape('%3C')+'\!-'+'-')"."\n"; |
|
|
$script .= '//--></script><noscript><a href="http://www.omniture.com" title="Web Analytics"><img src="'; |
|
|
$script .= check_plain(variable_get("omniture_image_file_location", 'http://examplecom.112.2O7.net/b/ss/examplecom/1/H.13--NS/0')) .'"'."\n"; |
|
|
$script .= 'height="1" width="1" border="0" alt="" /></a></noscript><!--/DO NOT REMOVE/-->'."\n"; |
|
|
$script .= '<!-- End SiteCatalyst code version: H.13. -->'."\n"; |
|
| 135 |
return $script; |
return $script; |
| 136 |
} |
} |
| 137 |
} |
} |
| 138 |
|
|
|
|
|
| 139 |
/** |
/** |
| 140 |
* Implementation of hook_admin_settings() for configuring the module |
* Implementation of hook_admin_settings() for configuring the module |
| 141 |
*/ |
*/ |
| 205 |
'#collapsed' => TRUE, |
'#collapsed' => TRUE, |
| 206 |
'#description' => t('You can add custom SiteCatalyst code here.') |
'#description' => t('You can add custom SiteCatalyst code here.') |
| 207 |
); |
); |
| 208 |
|
|
| 209 |
$form['advanced']['omniture_codesnippet'] = array( |
$form['advanced']['omniture_codesnippet'] = array( |
| 210 |
'#type' => 'textarea', |
'#type' => 'textarea', |
| 211 |
'#title' => t('JavaScript Code'), |
'#title' => t('JavaScript Code'), |
| 218 |
} |
} |
| 219 |
|
|
| 220 |
|
|
| 221 |
/* |
/** |
| 222 |
+++++++++++++++++++++++++++++++++++++++++++++++++++++ |
* Example output from the omniture.com site itself. |
| 223 |
Example code from the omniture.com site itself |
* Some of the paths may not be applicable for your site but at least it provides an example. |
| 224 |
Some of the paths may not be right for your site but at least it provides an example |
*/ |
|
+++++++++++++++++++++ |
|
|
|
|
| 225 |
|
|
| 226 |
/* |
/* |
| 227 |
|
|