This guides provides an overview of Loganis Query Script elements, like:
:met "ch0:ga:visitors"
:met
"ch0:ga:visitors"
{:met "ch4:ga:visits"
:beg "2013-03-21" :end "2013-04-17"
:dim "date"
:src :update
:fun {
"mean visits" (round (mean ch4:ga:visits)) ; rounded mean
"visits_diff1" (diff ch4:ga:visits) ; first derivative
"visits_diff2" (diff visits_diff1) ; second derivative
}
:col "date,mean visits,ch4:ga:visits,visits_diff1,visits_diff2"
}
absolute
or relative
date definitions:beg
defines the begin of the query period:end
defines the end of the query period:beg
and :end
in a queryYYYY-MM-DD
format used. like "2014-04-05"{
:beg "2014-01-01"
:end "2014-01-31"
}
:beg
and :end
definitions.last_1_month
last is called minor
, 1 is middle
, month is major
termMinor
term can be:
this
period, variable length from the beginning of the periodlast
period, fixed length period to yesterdayprev
period before last
periodMiddle
term can be an Integer numberMajor
term can be:
day
week
7 days4week
28 daysmonth
28 days or 4 weekscalmonth
calendar monthquarter
3 monthshalf
6 month or 1/2 yearyear
calendar year{
:per "last_1_month"
}
Always starts with a channel label string, then a channel type string
One Google Analytics Metric
{
:met "ch0:ga:visitors"
; Channel: ch0
; Channel type: ga (Google Analytics)
; Metric: ga:visitors
:per "last_1_month"
:dim "date"
}
{
:met "ch0:ga:visitors,ch0:ga:visits"
; Channel: ch0
; Channel type: ga (Google Analytics)
; Metrics: ga:visitors, ga:visits
:per "last_1_month"
:dim "date"
}
{
:met "ch0:ga:visitors,ch0:ga:visits,ch1:fb:page_impressions"
; Channel: ch0
; Channel type: ga (Google Analytics)
; Metrics: ga:visitors, ga:visits
:per "last_1_month"
:dim "date"
}
SELECT
ga:visitors FROM
ch1
{
:met "ch1:ga:visitors"
:per "last_1_month"
:dim "date"
}
SELECT
ga:visitors, ga:visits FROM
ch1
{
:met "ch1:ga:visitors,ch1:ga:visits"
:per "last_1_month"
:dim "date"
}
SELECT
ga:visitors FROM
ch1,ch2
{
:met "ch1:ga:visitors,ch2:ga:visitors"
:per "last_1_month"
:dim "date"
}
SELECT
ga:visitors,fb:page_impressions FROM
ch1,ch3
{
:met "ch1:ga:visitors,ch3:fb:page_impressions"
:per "last_1_month"
:dim "date"
}
ga:visitors
in a month can be segmented by a dimension like ga:city
in order to see which cities drives the most visitors to your site.dateyw
week of year [1-52]dateym
month of year [1-12]year
yeardate
YYYY-MM-DD format date, 2014-04-05
SELECT
ga:visitors FROM
ch1 GROUP BY
ga:city
{
:met "ch1:ga:visitors"
:dim "ga:city"
:per "last_1_month"
}
SELECT
ga:visitors, ga:visits FROM
ch1 GROUP BY
ga:city
{
:met "ch1:ga:visitors,ch1:ga:visits"
:dim "ga:city"
:per "last_1_month"
}
SELECT
ga:visitors FROM
ch1,ch2 GROUP BY
ga:city
{
:met "ch1:ga:visitors,ch2:ga:visitors"
:dim "ga:city"
:per "last_1_month"
}
:src
can be :update
, :direct
or :cache
:src :update
uses cache and fetches only missing data.:src :direct
uses no cache, all queries request data directly from GA or FB:src :cache
uses cache only:src
tag, then :update
will be used as default source of query:ord
tag:ord "ch0:ga:visits"
sort by ch0:ga:visits ascending:ord "-ch0:ga:visits"
sort by ch0:ga:visits descending:ord "ga:country,ga:city"
Sort first by ga:country then by ga:city[ ... ]
is an array of values#"..."
is a regexp{:per "last_1_month"
:met "ch4:ga:visitors"
:dim "ga:mobileDeviceModel"
:nod {"ga:mobileDeviceModel" {"Samsung" [ #"GT-.*" ]
"Nokia" [ #"Lumia.*"]
"Sony" ["WT19i" "E15i" #"C\d{4}" #"ST\d{2}.*"]
}
}
}
==
Equals
:fil "ga:timeOnPage==10"
!=
Does not equal
:fil "ga:timeOnPage!=10"
>
Greater than
:fil "ga:timeOnPage>10"
<
Less than
:fil "ga:timeOnPage<10"
>=
Greater than or equal to
:fil "ga:timeOnPage>=10"
<=
Less than or equal to
:fil "ga:timeOnPage<=10"
==
Exact match
:fil "ga:city==Irvine"
!=
Does not match
:fil "ga:city!=Irvine"
=@
Contains substring
:fil "ga:city=@York"
!@
Does not contain substring
:fil "ga:city!@York"
=~
Contains a match for the regular expression
:fil "ga:city=~^New.*"
!~
Does not match regular expression
:fil "ga:city!~^New.*"
:seg "dynamic::ga:source=~twitter"
Segment by ID
:seg "gaid::-3"
Examples for using segment:
Really Engaged Traffic
:seg "dynamic::ga:pageDepth>3;ga:timeOnSite>180"
3 keywords
:seg "dynamic::ga:keyword=~^\\s*[^\\s]+(\\s+[^\\s]+){2}\\s*$;ga:medium==organic"
4 keywords
:seg "ga:keyword=~^\\s*[^\\s]+(\\s+[^\\s]+){3}\\s*$;ga:medium==organic"
5 keywords
:seg "ga:keyword=~^\\s*[^\\s]+(\\s+[^\\s]+){4}\\s*$;ga:medium==organic"
6+ keywords
:seg "ga:keyword=~^\\s*[^\\s]+(\\s+[^\\s]+){5}\\s*$;ga:medium==organic"
Branded organic traffic
:seg "ga:keyword=@cutroni,ga:keyword=@brand;ga:medium=@organic
Non-Branded organic traffic
:seg "ga:keyword!@cutroni,ga:keyword!@brand;ga:medium=@organic"
Not Provided keyword traffic
:seg "ga:keyword=@(not provided)"
7+ keywords
:seg "ga:keyword=~^\\s*[^\\s]+(\\s+[^\\s]+){6,}\\s*$;ga:medium=@organic"
Ad position Top
:seg "ga:adSlot=@Top"
Ad position RHS (Right hand side)
:seg "ga:adSlot=@RHS"
Google Adwords CPC
:seg "ga:medium=@cpc;ga:source=@google"
Generic Keywords- Branded Ad Text
:seg "ga:adContent=@brand,ga:keyword!@brand"
Sitelink in landing page
:seg "ga:landingPagePath=@sitelink"
Paid Branded keywords
:seg "ga:keyword=@brand;ga:medium=@cpc|ppc"
Paid generic terms excluding Brand
:seg "ga:keyword!@brand;ga:medium=@cpc|pp"
{
:max 10 ; Query max 10 rows
:met "ch2:ga:visitors"
:per "last_1_month"
:dim "date"
}
{
;; Top 10 days in last month when most visitors arrived
:lim 10 ; Return first 10 rows only after processing
:met "ch2:ga:visitors"
:per "last_1_month"
:dim "date"
:ord "-ch2:ga:visitors"
}
:col "ch0:ga:visits,ch0:ga:visitors"
:tra true
:daily
, :weekly
or :monthly
{
:met "ch1:ga:visitors"
:per "last_4_week"
:dim "date"
:frq :daily
}
:weekly
date dimension is dateyw
(week of the year){
:met "ch1:ga:visitors"
:per "last_4_week"
:dim "dateyw"
:frq :weekly
}
:monthly
date dimension is dateym
(month of the year){
:met "ch1:ga:visitors"
:per "last_4_week"
:dim "dateym"
:frq :monthly
}
:query [list of object-ids]
:key "column name"
:col "column names separated by a comma"
Default join key is date
Example 1
{
:joi {:query ["521f0cd1e4b0f10cb48a6392" "52207ba6e4b0fdc12a933d0c"]}
; minimal join query, join 2 queries by date, show all columns
}
{
:joi {:query ["521f0cd1e4b0f10cb48a6392" "52207ba6e4b0fdc12a933d0c"]}
:key "date"
:col "date,ch1:ga:visits,ch2:ga:visits"
}
:chart
tag needs a matrix array
2x2
dashboard definition [[[chart1][chart2]][chart3][chart4]]
"524aa20ae4b0c2f2d313a807"
|
character: "title1 logscale|tooltip text"
(Tooltip text can contain HTML tags):label
tags need 1 dashboard title and a group title for each row:next
optional tag can refer to a next
dashboard and includes an HTML link in final dashboard.exported
to see it.{:dsh {:chart [
[ ; This is row 1 group, 6+6 wide
["524aa20ae4b0c2f2d313a807" "title1 logscale|tooltip text" 6]
["521dd1f1e4b053cf3f34ddca" "title2 candle|tooltip text" 6]
]
[ ; This is row 2 group, 3+6+3 wide
["52303bdce4b02b20312dcdce" "title3 combo|tooltip text" 3]
["52304d9ce4b02b20312dd4ff" "title4 map|tooltip text" 6]
["52305528e4b02b20312ddd23" "title5 scatter trendb|tooltip text" 3]
]
]
:label ["Dashboard label" "Row1 group label" "Row2 group label"]
:next "521f0cd1e4b0f10cb48a6392"
}
}
:fun
creates a new column Sum
that is the sum of 2 base metrics and Sum2
that refers to Sum
.{:met "ch0:ga:visits,ch1:ga:visits"
:dim "date"
:per "last_1_week"
:fun {
"Sum" ($= ch0:ga:visits + ch1:ga:visits)
"Sum2" ($= Sum * 2)
}}
{
:met "ch0:ga:visits,ch0:ga:avgTimeOnPage"
:per "last_1_week"
:dim "ga:country"
:fun {"ws-visits" (wsort ch0:ga:visits ch0:ga:avgTimeOnPage )}
:ord "-ws-vsits"
}
(wsort value-column weight-column)
Weighted sort values for each row(wmean value-column weight-column)
Weighted mean for result dataset($= column1 operator column2)
general arithmetic operations (+,-,*,/)(log column)
natural logarithm(log2 column)
base 2 logarithm(log10 column)
base 10 logarithm(mean column)
calculate average of a column(min column)
smallest value of a column(max column)
biggest value of a column(round column)
round values of a column to integer(round2 column)
round values of a column to 2 digit fraction(median column)
median value of a column(sd column)
standard deviation of a column(diff column)
derivation values of a column(norm column)
normalize values of a column between 0 and 1(share column)
calculates percent of values of the total sum of column