Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi To All!
Im having a problem in Google Analytics loading datas.
As you know, the Google Api have some limits and you have to parse loading to extract datas.
So, you have two ways to do it. First one its to parse loading in month but repeating the script part of loading and changing the Date_Start and the Date_End.
The problem its that the script will grow up every month and you have superfluous code.
The other way its to implement a Loop and using variables to build the dates. Code looks like this:
------------------------------------------------------------------------------------------------------------------------------------
set año = 2012;
set mes = 12;
set pasa = 0;
for año = 2012 to 2011 step -1
for mes = 12 to 1 step -1
set gDateStart = '$(año)-$(mes)-01';
set gDateEnd = '$(año)-$(mes)-28';
// Dimensions & Metrics Reference
SET gDimensions='ga:date,ga:campaign,ga:medium,ga:adGroup';
SET gMetrics='ga:impressions,ga:adClicks,ga:adCost,ga:CPM';
EXECUTE java -jar GoogleAnalyticsClient-20100623.jar -u $(gUserName) -p $(gPassword) -f $(gProfileId) -d $(gDimensions) -m $(gMetrics) -s $(gDateStart) -e $(gDateEnd) -o $(VPath)visitsSPR_AW.csv --max-results=10000000;
Analisis_AdWords:
LOAD
ga:date as ad:date,
Year(ga:date) & '-' & Month(ga:date) as AñoMes_ad:date,
Week(ga:date) as Semana_ad_date,
WeekDay(ga:date) as WeekDay_ad:date,
ga:campaign as ad:campaign,
ga:medium as ad:medium,
if (ga:medium = 'cpc' or ga:medium = 'ppc' or
ga:medium = 'cpa' or ga:medium = 'cpm' or
ga:medium = 'cpv'or ga:medium = 'cpp', 'Trafico_Pago', 'Organico') as ad:Clasif_Trafico,
ga:adGroup as ad:adGroup,
ga:impressions as ad:impressions,
ga:adClicks as ad:adClicks,
num#(ga:adCost, '#.#', '.' , ',' ) as ad:adCost,
num#(ga:CPM, '#.#', '.' , ',' ) as ad:CPM,
'example' as ad:perfil
FROM
$(VPath)visitsSPR_AW.csv
(txt, codepage is 1252, embedded labels, delimiter is ',', msq);
for I=1 to 10000
set pasa=0;
next
next
next
--------------------------------------------------------------------------------------------------------------------------------------------
Whats the problem? Well, the problem its that it works repeating the code... and it birngs datas every month. But, into the loop only returns datas a few months, not all.
Can Someone had the same problem?
Thanks to All!!
Regards. Germán
I didn't look into details but you may try putting variable after NEXT and see if that makes any difference.
next I
next mes
next año
Also, you can generate all the files in the loop and then load once all the files in LOAD statement. So you would be creating all the files with visitsSPR_AW_1.csv, visitsSPR_AW_2.csv... names and then in LOAD you can load with visitsSPR_AW_*.csv. This way you would know if all the files are being generated in the first place or not and will help you trouble shoot the issue.