WordPress.org

Ready to get started?Download WordPress

Forums

Google Analytics for WordPress
Code for image traffic in custom code box (1 post)

  1. Click-Factor
    Member
    Posted 1 year ago #

    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/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic