You are here

function ga_push_method_analytics_js_push_script in GA Push 8

Same name and namespace in other branches
  1. 7 inc/ga_push.analytics_js.inc \ga_push_method_analytics_js_push_script()

Generate the GA Push script code by type.

Parameters

array $push: Push data.

string $type: Push type.

Return value

string Script code.

3 calls to ga_push_method_analytics_js_push_script()
GAPushUnitTestCase::testGaPushMethodAnalyticsJSPushScriptEvent in test/ga_push.test
Unit test for ga_push_method_analytics_js_push_script(): Event.
GAPushUnitTestCase::testGaPushMethodAnalyticsJSPushScriptSocial in test/ga_push.test
Unit test for ga_push_method_analytics_js_push_script(): Social.
ga_push_method_analytics_js_push in inc/ga_push.analytics_js.inc
Send the ga push to JS on page load using Universal Analytics Event Tracking.

File

inc/ga_push.analytics_js.inc, line 60
Universal Analytics js: method and functions.

Code

function ga_push_method_analytics_js_push_script(array $push, $type) {
  switch ($type) {
    case GA_PUSH_TYPE_EVENT:
      $script = _ga_push_method_analytics_js_push_event_script($push);
      break;
    case GA_PUSH_TYPE_ECOMMERCE:
      $script = _ga_push_method_analytics_js_push_ecommerce_script($push);
      break;
    case GA_PUSH_TYPE_EXCEPTION:
      $script = _ga_push_method_analytics_js_push_send_script($push, 'exception');
      break;
    case GA_PUSH_TYPE_PAGEVIEW:
      $script = _ga_push_method_analytics_js_push_send_script($push, 'pageview');
      break;
    case GA_PUSH_TYPE_SOCIAL:
      $script = _ga_push_method_analytics_js_push_send_script($push, 'social');
      break;
    default:
      $script = NULL;
  }
  return $script;
}