PrivatusAnalytics.Config (Privatus Analytics v1.0.0)

Copy Markdown View Source

Reads the settings for the tracking script.

Settings come from three places. The first one found wins:

  1. Options passed to the call (for example PrivatusAnalytics.tag(modules: ["engage"])).
  2. Application config, config :privatus_analytics, ....
  3. Built-in defaults (and the PRIVATUS_SITE_ID and PRIVATUS_SCRIPT_HOST environment variables for the site id and script host).

Which environments get the tag

enabled: true or enabled: false forces the tag on or off. When enabled is not set, the tag prints only when the current environment is in enabled_environments (default [:prod]). The current environment is:

  • the :env setting, if you set it (we recommend config :privatus_analytics, env: config_env() in config/config.exs),
  • else Mix.env() when Mix is running (mix phx.server, mix test),
  • else :prod. Mix is not part of a release, so a release counts as production.

Summary

Functions

The tracker origin used when nothing else is set.

Whether the tag should print for these options.

The environment used to decide if the tag prints. See the module docs.

The origin that serves /js/pa.js, without a trailing slash.

The site id (starts with pa_), or nil. Falls back to PRIVATUS_SITE_ID.

Functions

default_host()

The tracker origin used when nothing else is set.

enabled?(opts \\ %{})

Whether the tag should print for these options.

env(opts \\ %{})

The environment used to decide if the tag prints. See the module docs.

script_host(opts \\ %{})

The origin that serves /js/pa.js, without a trailing slash.

site_id(opts \\ %{})

The site id (starts with pa_), or nil. Falls back to PRIVATUS_SITE_ID.