Analytics by Emerge2

Documentation

This Javascript library makes it easy to do analytics tracking for websites using Google Analytics 4 and/or a Facebook Pixel.

To take all defaults, you only need to embed a short script block into your website and add your Google Analytics 4 and/or Facebook Pixel ID(s), and the tracking begins.

It will automatically not do logging when invoked in the following situations:

  • invoked from a known bot
  • invoked from an admin session
  • invoked from a blocked IP address range (if you specify an IP address range to block, e.g. your office so that staff activity doesn't skew the public usage stats)
  • invoked when the URL contains the optional variable ?e2monitor=x or &e2monitor=x (you can optionally use one of these variables in your site uptime monitoring tool to avoid tracking the invocations of your website which are done by your site uptime monitor)

Fragmented "Referrer URLs" are combined so that your Page View stats are not eroded through the use of many subdomains from the same online system, e.g. usage from l.facebook.com, lm.facebook.com, m.facebook.com, apps.facebook.com, etc., are all recorded with a normalized referrer URL of facebook.com. The same for other known fragmented referrer URL sources from popular online platforms. This default defragmentation can be disabled.

Example for Google Analytics 4 tracking

<script type="text/javascript">
 var e2_analytics_ga4_id = 'G-xxxxxxxx';
 var e2_analytics_is_misc = true;
</script>
<script src="https://common.emerge2.com/emerge2_analytics_v3.js" type="text/javascript"></script>

Example for both Google Analytics 4 and Meta/Facebook Pixel tracking

<script type="text/javascript">
  var e2_analytics_ga4_id = 'G-xxxxxxxx';
  var e2_analytics_fb_pixel_id = 'nnnnnnnnnnnnnn';
  var e2_analytics_is_misc = true;
</script>
<script src="https://common.emerge2.com/emerge2_analytics_v3.js" type="text/javascript"></script>

Many optional parameters can also be passed (see below), but the above two scenarios are very common.

e2_analytics_is_{TYPE} Parameter

One (and only one) of the following "e2_analytics_is_{TYPE}" parameters must be included to tell the logic what type of website it is:

  var e2_analytics_is_builder = true; // a Builder.io site
  var e2_analytics_is_gc = true; // a Galileo Commerce site
  var e2_analytics_is_volusion = true; // a Volusion site
  var e2_analytics_is_wordpress = true; // a WordPress site
  var e2_analytics_is_misc = true; // for all other site types

The site type is used by a variety of subsections to determine, for example, when a user is within an admin session, to determine which unneeded URL query parameters should be removed, etc.

Passable Parameters

Each of the following parameters can be specified in a Javascript "var" statement with its associated value enclosed in single or double quotes (except for the true/false values which should not be enclosed within quotes). Each such statement must end with a ";" and must be specified before invoking the "emerge2_analytics_v3.js" script. For example:

<script type="text/javascript">
  var e2_analytics_ga4_id = 'G-xxxxxxxx';
  var e2_analytics_is_wordpress = true;
  var e2_analytics_bypass_ip_addresses = "64.209.168.";
  var e2_analytics_currency_code = "USD";
</script>
<script src="https://common.emerge2.com/emerge2_analytics_v3.js" type="text/javascript"></script>
Input VariablesValuesPurpose
e2_analytics_ga4_id G-xxxxxxxx The Google Analytics 4 (GA4) property ID for your site (sometimes called the "Measurement ID" from your Data Stream).
e2_analytics_ga4_id_2 G-xxxxxxxx To also record your usage to a second GA4 ID. This is sometimes used to aggregate the usage from a group of related sites into one Show More
e2_analytics_ga4_id_3 G-xxxxxxxx To also record your usage to a third GA4 ID.
e2_analytics_ga4_id_4 G-xxxxxxxx To also record your usage to a fourth GA4 ID.
e2_analytics_fb_pixel_id nnnnnnnnnnnn To record your usage to a Meta/Facebook Pixel ID.
e2_analytics_bypass_ip_addresses nnn.nnn.nnn.nnn
nnn.nnn.nnn.
nnn.nnn.
Do not track any invocations from a user IP address that begins with this value. For example, if the value is "64.209.168." then ignore Show More
e2_analytics_currency_code 3-digit Currency Code

The default currency of the amounts passed for order total, shipping, tax, product prices, etc. This functionality requires the invoking of a Show More
e2_analytics_diagnostics true or false
Default: false
Display diagnostic or interim progress messages on the browser's Inspect Console during script processing while experimenting with options.
e2_analytics_display_contact_info true or false
Default: false
Display instructions on the browser's Inspect Console regarding how to email or submit a support ticket to Emerge2.
e2_analytics_display_removable_query_vars true or false
Default: false
Display on the browser's Inspect Console the list of known unnecessary URL query parameters which will be removed Show More
e2_analytics_defrag_query_vars true or false
Default: true
If false, then disable the normal removal of known unnecessary URL query parameters before recording the URL invocation. Show More
e2_analytics_defrag_referrer true or false
Default: true
If false, then disable the normal defragmentation of the "Referrer URL" from popular online platforms, resulting in fragmented Show More
e2_analytics_is_builder true or false
Default: false
This is being invoked from a Builder.io site.
e2_analytics_is_gc true or false
Default: false
This is being invoked from a Galileo Commerce (GC) site.
e2_analytics_is_volusion true or false
Default: false
This is being invoked from a Volusion site.
e2_analytics_is_wordpress true or false
Default: false
This is being invoked from a WordPress site.
e2_analytics_is_misc true or false
Default: false
This is being invoked from another type of site (not Builder.io, GC, Volusion, or WordPress). This is the default if no other e2_analytics_is_* variable is set to true.

 

Question and Answer

Technical Questions

If you have any questions regarding this utility, please contact e2eae631Flbb8Sz5XSZ_rhjni8g8j48pZMhg|.