const mixinafGoogleAnalytics::GoogleAnalytics

afGoogleAnalytics::GoogleAnalytics

(Service) - Renders the Google Universal Analytics script and sends page views and events.

See analytics.js for details.

accountDomain

Source

abstract Str? accountDomain()

Returns the domain used to setup the google script.

accountNumber

Source

abstract Str accountNumber()

Returns the account used to setup the google script.

pageViewRendered

Source

abstract Bool pageViewRendered()

Returns true if the page has already rendered Javascript to send a page view event.

This allows individual pages to send page views for canonical URLs and a layout component to send general page views if the page hasn't done so.

renderCmd

Source

abstract Void renderCmd(Str cmd, Obj? arg1 := null, Obj? arg2 := null, Obj? arg3 := null, Obj? arg4 := null)

Renders Javascript to add an arbitrary command to the command queue. Example:

renderCmd("create", "UA-XXXXX-Y", "auto")

would render:

ga('create', 'UA-XXXXX-Y', 'auto');

Arguments have toStr executed on them before rendering.

If the last argument is a Map, then it is serialised as JSON and used as the fieldsObject. Example:

renderCmd("create", [
    "trackingId"   : "UA-XXXXX-Y",
    "cookieDomain" : "auto"
])

would render:

ga('create', {
    'trackingId'   : 'UA-XXXXX-Y',
    'cookieDomain' : 'auto'
});
renderEvent

Source

abstract Void renderEvent(Str category, Str action, Str? label := null, Num? value := null, [Str:Obj?]? fieldOptions := null)

Renders Javascript to send an event to google analytics.

renderPageView

Source

abstract Void renderPageView(Uri? url := null, [Str:Obj?]? fieldOptions := null)

Renders Javascript to send a page view to google analytics. If url is given then it should start with a leading /, e.g. /about

Note that if a URL is NOT supplied, then the query string is stripped from the rendered URL. This usually makes sense for Fantom web apps as query strings do not generally denote unique pages.