Support » Plugin: Google Analytics for WordPress by MonsterInsights » Code for image traffic in custom code box

  • Hello I’m trying to add the following code I found for separating traffic from image search.

    [ Moderator note: please wrap code snippets in the backtick character or use the code button. Not the blockquote. ]

    var ref = document.referrer;
    if (ref.search(/google\.([^\/]+)\/(ima?g|.*[?&]tbm=isch|.*[?&]site=images)/i) != -1) {
      var regex = /google\.([^\/]+)\/.*/i;
      var match = regex.exec(ref);
    
      if (ref.search(/[?&]prev=/i) != -1) {
        regex = /[?&]prev=([^&]*)/i;
        var match2 = regex.exec(ref);
        _gaq.push(['_addOrganic','images.googleSerps','q',true]);
        _gaq.push(['_setReferrerOverride', 'http://images.googleSerps.'+match[1]+unescape(match2[1])]);
    
      } else {
        _gaq.push(['_addOrganic','images.google','q',true]);
        _gaq.push(['_setReferrerOverride', 'http://images.'+match[0]]);
      }
    }

    Unfortunately, after updating I get a “Nothing found” page.
    Can someone hint what’s wrong with this?

    http://wordpress.org/extend/plugins/google-analytics-for-wordpress/

  • The topic ‘Code for image traffic in custom code box’ is closed to new replies.