title: New Google analytics API - how to send search, 404 info for tracking
body: <p>Am working on a custom code to send the user search details and when ever 404 happens on the store. For that I have something like following </p>
  
  <pre><code>    &lt;?php
          $page = '404';
          if ($page == '404') {
              $result[] = "ga('send', 'pageview', { 'page': '404/?url='+ document.location.href + document.location.search +'&amp;ref=' + document.referrer,  'title': '404 Error'});";            
          }
          $searchText = 'abc';
          $searchResultCount = 0;// or number of records on search query
          if ($searchText != '') {
              if ($searchResultCount == 0) {
                  $result[] = "ga('send', 'pageview', { 'page': $searchText,  'title': 'Search No rsult'});";   
              } else {
                  $result[] = "ga('send', 'pageview', { 'page': $searchText,  'title':  $searchResultCount.' Found on Search'});";
              }
          }
  
          $moreTracking = implode("\n", $result);
  
   ?&gt;
  
    &lt;!-- BEGIN GOOGLE UNIVERSAL ANALYTICS CODE --&gt;
      &lt;script type="text/javascript"&gt;
          //&lt;![CDATA[
          (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
              (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
              m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
          })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
          ga('create', 'UA-&lt;?php echo $accountId; ?&gt;-1', 'auto');
          ga('send', 'pageview');
          &lt;?php echo $moreTracking; ?&gt;
  
          //]]&gt;
      &lt;/script&gt;
      &lt;!-- END GOOGLE UNIVERSAL ANALYTICS CODE --&gt;
  </code></pre>
  
  <p>Am I adding it correctly? for to track 404 errors and search result or no search records found for user query.</p>