Liking cljdoc? Tell your friends :D

privatus.analytics

Prints the cookieless Privatus Analytics tracking script and the HTML attributes the tracker reads for custom events and click maps.

This library only builds HTML. It never sends events from the server, sets no cookies and reads nothing about the visitor.

Prints the cookieless Privatus Analytics tracking script and the HTML
attributes the tracker reads for custom events and click maps.

This library only builds HTML. It never sends events from the server, sets
no cookies and reads nothing about the visitor.
raw docstring

*warn*clj

Called with a message when a click map name is not valid. By default it prints to stderr, except when PRIVATUS_ENV is production. Rebind it to send the warning to your logger, or to (constantly nil) to keep quiet.

Called with a message when a click map name is not valid. By default it
prints to stderr, except when PRIVATUS_ENV is production. Rebind it to send
the warning to your logger, or to (constantly nil) to keep quiet.
sourceraw docstring

attrs->htmlclj

(attrs->html attrs)

Turns an attribute map into HTML, with every value escaped. true prints the bare name, nil and false print nothing.

Turns an attribute map into HTML, with every value escaped.
true prints the bare name, nil and false print nothing.
sourceraw docstring

click-attrclj

(click-attr click-map-name)

The click map name attribute, as a map: {:data-privatus-click "pricing.cta"}. Gives {} when the name is not valid.

The click map name attribute, as a map: {:data-privatus-click "pricing.cta"}.
Gives {} when the name is not valid.
sourceraw docstring

click-attr-htmlclj

(click-attr-html click-map-name)

The click map attribute as escaped HTML: data-privatus-click="pricing.cta".

The click map attribute as escaped HTML: data-privatus-click="pricing.cta".
sourceraw docstring

default-script-hostclj

source

enabled?clj

(enabled? config)

true or false in :enabled forces the tag on or off. Otherwise the tag is on only when the PRIVATUS_ENV environment variable is production.

true or false in :enabled forces the tag on or off. Otherwise the tag is on
only when the PRIVATUS_ENV environment variable is production.
sourceraw docstring

escape-htmlclj

(escape-html v)

Escapes & < > " and ' for use in HTML text or attribute values.

Escapes & < > " and ' for use in HTML text or attribute values.
sourceraw docstring

event-attrsclj

(event-attrs event-name)
(event-attrs event-name props)

Attributes for a custom event, as a map with keyword keys. Put it straight into a Hiccup element:

[:button (event-attrs "Report exported" {:format "csv"}) "Export"]

The name is trimmed and cut to 120 characters. An empty name gives {}. On a <form> the event is sent when the form is submitted.

Attributes for a custom event, as a map with keyword keys. Put it straight
into a Hiccup element:

  [:button (event-attrs "Report exported" {:format "csv"}) "Export"]

The name is trimmed and cut to 120 characters. An empty name gives {}.
On a <form> the event is sent when the form is submitted.
sourceraw docstring

event-attrs-htmlclj

(event-attrs-html event-name)
(event-attrs-html event-name props)

The event attributes as escaped HTML, for string templates like Selmer:

<button {{export-attrs|safe}}>Export</button>

The event attributes as escaped HTML, for string templates like Selmer:

<button {{export-attrs|safe}}>Export</button>
sourceraw docstring

markerclj

Text that shows a page already has the tracker tag.

Text that shows a page already has the tracker tag.
sourceraw docstring

normalize-keyclj

(normalize-key k)

Lowercases a prop key, swaps anything outside a-z 0-9 _ for _ and cuts it to 64 characters.

Lowercases a prop key, swaps anything outside a-z 0-9 _ for _ and cuts it
to 64 characters.
sourceraw docstring

normalize-propsclj

(normalize-props props)

Clean prop pairs, in order: keys normalised, nil values dropped, at most 30.

Clean prop pairs, in order: keys normalised, nil values dropped, at most 30.
sourceraw docstring

page-propsclj

(page-props config)
(page-props config overrides)

The configured props for one request, with per call props merged on top. :props in the config may be a map or a function that gets the request.

The configured props for one request, with per call props merged on top.
:props in the config may be a map or a function that gets the request.
sourceraw docstring

page-props-jsonclj

(page-props-json props)

Page props as a JSON object that is safe inside a <script>, or nil when there is nothing to send. Numbers and booleans stay JSON numbers and booleans, lists stay arrays (at most 30 items). < > & U+2028 and U+2029 are escaped.

Page props as a JSON object that is safe inside a <script>, or nil when there
is nothing to send. Numbers and booleans stay JSON numbers and booleans, lists
stay arrays (at most 30 items). < > & U+2028 and U+2029 are escaped.
sourceraw docstring

props-functionclj

source

queue-stubclj

The tracker's official queue stub. It keeps privatus.track calls made before pa.js loads and the tracker sends them later.

The tracker's official queue stub. It keeps privatus.track calls made before
pa.js loads and the tracker sends them later.
sourceraw docstring

render?clj

(render? config)

Whether the tag prints: there is a site id and the tag is enabled.

Whether the tag prints: there is a site id and the tag is enabled.
sourceraw docstring

script-hostclj

(script-host config)

Where /js/pa.js is served: the config, PRIVATUS_SCRIPT_HOST, or https://privatusstats.com. A trailing slash is removed.

Where /js/pa.js is served: the config, PRIVATUS_SCRIPT_HOST, or
https://privatusstats.com. A trailing slash is removed.
sourceraw docstring

site-idclj

(site-id config)

The site id from the config, or the PRIVATUS_SITE_ID environment variable.

The site id from the config, or the PRIVATUS_SITE_ID environment variable.
sourceraw docstring

spa-modesclj

source

tagclj

(tag)
(tag config)
(tag config overrides)

The Privatus Analytics script tag as an HTML string. Put it in the <head>.

(tag {:site-id "pa_YOURSITEID"}) (tag config {:request request :props {:section "billing"}})

config keys (all optional): :site-id :script-host :modules :excluded-paths :domains :spa :manual :enabled :extra-attributes :props :queue-stub :nonce. overrides: any config key, plus :request (passed to a :props function) and :props (merged over the configured props; a nil value removes one).

Without a site id or when the tag is not enabled, gives only the queue stub script when :queue-stub is on, else "".

The Privatus Analytics script tag as an HTML string. Put it in the <head>.

  (tag {:site-id "pa_YOURSITEID"})
  (tag config {:request request :props {:section "billing"}})

config keys (all optional): :site-id :script-host :modules :excluded-paths
:domains :spa :manual :enabled :extra-attributes :props :queue-stub :nonce.
overrides: any config key, plus :request (passed to a :props function) and
:props (merged over the configured props; a nil value removes one).

Without a site id or when the tag is not enabled, gives only the queue stub
script when :queue-stub is on, else "".
sourceraw docstring

tag-partsclj

(tag-parts config)
(tag-parts config overrides)

The parts of the tag as data, or nil when nothing should print: {:queue-stub js-or-nil, :props-script js-or-nil, :nonce str-or-nil, :attrs ordered-map-of-tracker-attributes-or-nil}.

When the tag is off (not enabled, or no site id) and :queue-stub is on, only {:queue-stub js :nonce str-or-nil} is given (no tracker and no page props; a :props function is not called), so privatus.track calls never fail.

The parts of the tag as data, or nil when nothing should print:
{:queue-stub js-or-nil, :props-script js-or-nil, :nonce str-or-nil,
 :attrs ordered-map-of-tracker-attributes-or-nil}.

When the tag is off (not enabled, or no site id) and :queue-stub is on, only
{:queue-stub js :nonce str-or-nil} is given (no tracker and no page props;
a :props function is not called), so privatus.track calls never fail.
sourceraw docstring

tracker-attrsclj

(tracker-attrs config)
(tracker-attrs config overrides)

The tracker <script> attributes as an ordered map with string keys.

The tracker <script> attributes as an ordered map with string keys.
sourceraw docstring

valid-click?clj

(valid-click? click-map-name)

Whether a click map name is valid: letters, digits, _ . : - and at most 100 characters.

Whether a click map name is valid: letters, digits, _ . : - and at most 100
characters.
sourceraw docstring

versionclj

source

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close