Google Analytics API calculate internal referrals.

I can find out the traffic sources for a page with a given permalink from the Google Analytics API that return a result like this:

Array(
    [direct] => 1
    [social] => 0
    [3rdparty] => 0
    [search] => 0
)

using a query call like this:

public static function get_traffic_sources( $args ) {
        global $post;


        $default = array(
            'per_days' => 30 ,
            'skip' => 0,
            'query' => 'traffic_sources',
            'path' => Inbound_Google_Connect::get_relative_permalink( $post->ID )
        );

        $request = array_replace( $default , $args );

        return Inbound_Google_Connect::load_data( $request );
    }

But I would like to find out the number of internal referrals. Google does not seem to include this in their traffic_sources query. Any leads on how I could get this extra bit of information?

Answers


I'm not sure what you mean by internal referrals - I guess yo mean "the internal link that got a user to the current page" ? Since internal links are not traffic sources (which in Google Lingo means "whatever brought the user to the currently tracked property") you have to look for the previous page path via ga:previousPagePath (which for me in the query explorer only worked after I combined it with a filter for a specific page). I'm not quite sure which API client library you are using there, so you'd have to figure out yourself how to set dimensions in the query.


Need Your Help

Qsort array of strings in alphabetical order

c arrays qsort

Im trying to sort a array of strings I read from a file in alphabetical order using the qsort function. This is my code: