Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A Little Help #1

Open
MikeSLC opened this issue Mar 12, 2014 · 7 comments
Open

A Little Help #1

MikeSLC opened this issue Mar 12, 2014 · 7 comments

Comments

@MikeSLC
Copy link

MikeSLC commented Mar 12, 2014

I am so thankful for what you have done. I would be stuck without it.

I am having some small issues.

I can't figure out how to use the filters. I don't see anything on it in the documentation, and I'm not that smart.

I am using this code:
List<Analytics.Data.DataItem> metrics = new List<Analytics.Data.DataItem>();
//metrics.Add(Analytics.Data.Visitor.Metrics.visitors);
metrics.Add(Analytics.Data.Session.Metrics.visits);
//metrics.Add(Analytics.Data.Session.Metrics.timeOnSite);
metrics.Add(Analytics.Data.Adwords.Metrics.adClicks);
metrics.Add(Analytics.Data.Adwords.Metrics.adCost);
metrics.Add(Analytics.Data.Adsense.Metrics.adsenseAdsClicks);
//metrics.Add(Analytics.Data.Adsense.Metrics.adsenseRevenue);
metrics.Add(Analytics.Data.Session.Metrics.Calculated.visitBounceRate);
//metrics.Add(Analytics.Data.Session.Metrics.
List<Analytics.Data.DataItem> dimensions = new List<Analytics.Data.DataItem>();
//dimensions.Add(Analytics.Data.GeoNetwork.Dimensions.country);
//dimensions.Add(Analytics.Data.GeoNetwork.Dimensions.city);
dimensions.Add(Analytics.Data.TrafficSources.Dimensions.campaign);
dimensions.Add(Analytics.Data.TrafficSources.Dimensions.keyword);
List<Analytics.Data.DataItem> filters = new List<Analytics.Data.DataItem>();
filters.Add(Analytics.Data.Session.Metrics.visits);

        System.Data.DataTable table = manager.GetGaDataTable(DateTime.Today.AddDays(-5), DateTime.Today, metrics, dimensions, filters, metrics);

Unfortunately, it seems to filter off all results. I want my list to include anything that has over 50 visits. How would I do that?

You can also see that I have commented out adsenseRevenue, and timeOnSite. Both of these metrics throw a conversion error something like this:

String was not recognized as a valid DateTime.Couldn't store <0.0> in timeOnSite Column. Expected type is DateTime.

and...

Input string was not in a correct format.Couldn't store <2.52E-4> in adsenseRevenue Column. Expected type is Decimal.

I'm not smart enough to fix either problem.

I would really appreciate any help that you would be willing to provide.

Thanks,

Mike

ramyothman pushed a commit that referenced this issue Mar 12, 2014
@ramyothman
Copy link
Owner

@MikeSLC hey thanks a lot for the issue, well i fixed the time metric (date time) problem so you could use it now regarding the filter issue you could use the following code I added couple of methods
for filtering metrics (Equals, DoesNotEqual, GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual)

for filtering dimensions(Equals, DoesNotEqual, Contains, DoesNotContains, ContainsRegex, DoesNotContainsRegex)

List<Analytics.Data.DataItem> filters = new List<Analytics.Data.DataItem>();
Analytics.Data.DataItem country = new Analytics.Data.DataItem(Analytics.Data.GeoNetwork.Dimensions.country.Name);
country.Equals("Saudi Arabia");
filters.Add(country);
System.Data.DataTable table = manager.GetGaDataTable(DateTime.Today.AddDays(-3), DateTime.Today, metrics, dimensions, filters, metrics, true);

@MikeSLC
Copy link
Author

MikeSLC commented Mar 12, 2014

Thank you so much. I'm still having trouble with the one other conversion error. When I include the column adsenseRevenue, I get the error:

Input string was not in a correct format.Couldn't store <2.52E-4> in adsenseRevenue Column. Expected type is Decimal.

@MikeSLC
Copy link
Author

MikeSLC commented Mar 12, 2014

One other thing that would really help. I'm using VS2010. Is it possible to make a build that targets 4.0 framework?

@ramyothman
Copy link
Owner

hey, @MikeSLC regarding the adsenseRevenue it's working here fine could you please post the value that raised the error

@MikeSLC
Copy link
Author

MikeSLC commented Mar 13, 2014

The value was something like 2.65E-6. Unfortunately, I can't tell you know because it just bombs out when I include the adsenseRevenue. If I comment out the line that includes that parameter:
metrics.Add(Analytics.Data.Adsense.Metrics.adsenseRevenue);
I get lots of results. If I include it, I get no results. The error happens in the line of BuildTableRows where the assignment is made. I put a break point there to see if I could catch it again. When I include the above mentioned metrics.Add line, I never get to that point in the code. When the adsenseRevenue line is commented out, I go there over and over again (as you would expect).

@ramyothman
Copy link
Owner

ok check it out now it should be ok

@MikeSLC
Copy link
Author

MikeSLC commented Mar 14, 2014

It still returns no rows when I include adsenseRevenue. I have included adsenseECPM, and that returns fine. That makes me suspect that nothing is wrong with the adsense data.

Here is my exact code in case it helps:

List<Analytics.Data.DataItem> metrics = new List<Analytics.Data.DataItem>();
metrics.Add(Analytics.Data.Session.Metrics.visits);
metrics.Add(Analytics.Data.Session.Metrics.timeOnSite);
metrics.Add(Analytics.Data.Session.Metrics.Calculated.visitBounceRate);
metrics.Add(Analytics.Data.Adwords.Metrics.adCost);
metrics.Add(Analytics.Data.Adwords.Metrics.Calculated.CPM);
metrics.Add(Analytics.Data.Adwords.Metrics.Calculated.CPC);
metrics.Add(Analytics.Data.Adsense.Metrics.adsenseAdsClicks);
//metrics.Add(Analytics.Data.Adsense.Metrics.adsenseRevenue); only works when commented out
metrics.Add(Analytics.Data.Adsense.Metrics.adsensePageImpressions);
metrics.Add(Analytics.Data.Adsense.Metrics.Calculated.adsenseCTR);
metrics.Add(Analytics.Data.Adsense.Metrics.Calculated.adsenseECPM);
List<Analytics.Data.DataItem> dimensions = new List<Analytics.Data.DataItem>();
dimensions.Add(Analytics.Data.TrafficSources.Dimensions.campaign);
dimensions.Add(Analytics.Data.TrafficSources.Dimensions.keyword);
List<Analytics.Data.DataItem> filters = new List<Analytics.Data.DataItem>();

        //for filtering metrics (Equals, DoesNotEqual, GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual)
        //for filtering dimensions(Equals, DoesNotEqual, Contains, DoesNotContains, ContainsRegex, DoesNotContainsRegex)

        Analytics.Data.DataItem visits = new Analytics.Data.DataItem(Analytics.Data.Session.Metrics.visits.Name);
        visits.GreaterThan("0");

        filters.Add(visits);

        Analytics.Data.DataItem adClick = new Analytics.Data.DataItem(Analytics.Data.Adsense.Metrics.adsenseAdsClicks.Name);
        adClick.GreaterThan("0");

        filters.Add(adClick);

        System.Data.DataTable table = manager.GetGaDataTable(DateTime.Today.AddDays(-5), DateTime.Today, metrics, dimensions, filters, metrics, true);

ramyothman pushed a commit that referenced this issue Aug 30, 2017
Updating from base for further work
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants