Results 1 to 3 of 3
  1. #1
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Thread started by 'nervous' -- Trying to take data from google analytics ...

    Due to a known bug in the forum software, topics with the word 'print' in the thread title are rendered for printing, so replies can't be posted. The post by nervous is being reproduced here. Inconvenience is regretted.

    db

    Quote Originally Posted by nervous View Post
    Hi,

    I am trying to program a basic code to take information from google analytics and print it out. I wrote some code, whats wrong. (user/pass) removed for privacy reasons.

    I am trying to make it all occur in one class for now (Its the beta version to make sure I can download information and use it before I start the real program). I just want to take information and print it out. I know the table id isn't set, but the program won't compile:

    Exception in thread "main" java.lang.Error: Unresolved compilation problem:

    at xyz.xyzStart.main(xyzStart.java:96)

    ------

    package xyz;

    import com.google.gdata.client.analytics.AnalyticsService ;
    import com.google.gdata.client.analytics.DataQuery;
    import com.google.gdata.data.analytics.Aggregates;
    import com.google.gdata.data.analytics.DataEntry;
    import com.google.gdata.data.analytics.DataFeed;
    import com.google.gdata.data.analytics.DataSource;
    import com.google.gdata.data.analytics.Dimension;
    import com.google.gdata.data.analytics.Metric;
    import com.google.gdata.data.analytics.Segment;
    import com.google.gdata.util.AuthenticationException;
    import com.google.gdata.util.ServiceException;

    import java.io.IOException;
    import java.net.URL;
    import java.util.ArrayList;
    import java.util.List;




    public class xyzStart {

    private static final String id= "-";
    private static final String Pass = "-";
    public DataFeed feed;


    /**
    * trial run of program
    */
    public xyzStart(){
    // try{
    String started = "the program has started";
    System.out.println(started);
    dataFeedSet();
    printFeedData();
    // }

    //catch{

    // }catch{

    // }catch{
    }

    /**
    * Need to edit later, basics to be used/tinkered with
    *
    */
    public void dataFeedSet(){
    AnalyticsService as = new AnalyticsService("xyz.com");

    //authorization
    as.setUserCredentials(id, Pass);
    // GA Data Feed query uri.
    String baseUrl = "https://www.google.com/analytics/feeds/data";
    DataQuery query = new DataQuery(new URL(baseUrl));
    query.setIds(TABLE_ID);
    query.setDimensions("ga:source,ga:medium");
    query.setMetrics("ga:visits,ga:bounces");
    query.setSegment("gaid::-11");
    query.setFilters("ga:medium==referral");
    query.setSort("-ga:visits");
    query.setMaxResults(5);

    // allow user to preset? or alter?
    query.setStartDate("2011-06-01");

    //latest date solution? have user enter?
    query.setEndDate("2008-10-31");
    URL url = query.getUrl();
    System.out.println("URL: " + url.toString());

    // Send our request to the Analytics API and wait for the results to
    // come back.
    feed = as.getFeed(url, DataFeed.class);



    }

    public void printFeedData(){

    System.out.println("\n-------- Important Feed Information --------");
    System.out.println(
    "\nFeed Title = " + feed.getTitle().getPlainText() +
    "\nFeed ID = " + feed.getId() +
    "\nTotal Results = " + feed.getTotalResults() +
    "\nSart Index = " + feed.getStartIndex() +
    "\nItems Per Page = " + feed.getItemsPerPage() +
    "\nStart Date = " + feed.getStartDate().getValue() +
    "\nEnd Date = " + feed.getEndDate().getValue() +
    "\nContains Sampled Data = " + feed.getContainsSampledData().getValue().toString( ));
    }

    public static void main(String[] args) {

    }

    }
    Last edited by DarrylBurke; 06-21-2012 at 07:34 AM.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: Thread started by 'nervous' -- Trying to take data from google analytics ...

    Forum Rules
    Guide For New Members
    BB Code List - Java Programming Forum

    Please re-post the code with proper indentation and code tags. I didn't add them as the code has already lost all formatting due to being posted without tags.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default Re: Thread started by 'nervous' -- Trying to take data from google analytics ...


Similar Threads

  1. Replies: 3
    Last Post: 08-05-2014, 10:06 AM
  2. Trying to take data from google analytics and p
    By nervous in forum New To Java
    Replies: 0
    Last Post: 06-20-2012, 11:46 PM
  3. Deleting data while it's modified by a thread
    By AmFreak in forum Threads and Synchronization
    Replies: 3
    Last Post: 11-23-2011, 08:18 PM
  4. Replies: 1
    Last Post: 05-21-2011, 09:56 PM
  5. data from the main/GUI thread to another runnin thread...
    By cornercuttin in forum Threads and Synchronization
    Replies: 2
    Last Post: 04-23-2008, 11:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •