AGF Tracking Method Overview

Creation date: 4/18/2022 3:15 PM    Updated: 2/2/2023 8:06 AM
The AGF Tracking Method uses a JavaScript file and a tracking beacon to detect activity on your website | web application.

Here's how it works:
  • Add the Tracking Code reference to each Page of your website (via a header or footer)
  • When a Visitor loads a Page, the Tracking Code also loads
  • The Tracking Code sends a Tracking Beacon to your web server: one for each Page loaded
  • During processing, Angelfish uses the hits from the Tracking Beacon

The AGF Tracking Method is not required to use Angelfish.  However, if you want to use (or must use) a JavaScript-based Tracking Method, we recommend using the AGF Tracking Method.


INSTALLATION STEPS


1) UPLOAD TRACKING FILES

The AGF tracking method uses two files, uploaded to your website:
  • angelfish.js   (Tracking Code)
  • agf.gif            (Tracking Beacon)

We recommend uploading both Tracking Files to the root directory of the website you want to track.  That said, the Tracking Files can be placed in any directory.  

You can download the Tracking Files from the Angelfish Website from the
Custom Tracking Code Generator.

If you place the Tracking Files in a different directory, please note the following:
  • the Tracking Code Reference needs to contain the full path to angelfish.js
  • the Tracking File Path & Name field (in Custom Code Generator) needs the full path to agf.gif

Both Tracking Files are also in the /www/agf/ subdirectory of your Angelfish root directory, but the version of angelfish.js in this location is not current.


2) ADD TRACKING CODE REFERENCE

The following code snippet needs to be referenced in the HTML of every Page you want to track. The easiest way to accomplish this is to paste the snippet into the header or footer template - this automatically adds the code to each Page.

<script type="text/javascript" src="/angelfish.js"></script>
<script type="text/javascript">
  agf.pageview();
</script>

Once the code reference is in place, use a browser to verify everything works as expected:
  • load a Page on the website to you just added the code reference
  • open your Browser console (F12) 
  • click the Network tab
  • refresh the page
  • look for requests for angelfish.js & agf.gif - both should have a status code of 200

Once you see requests for angelfish.js & agf.gif, it means your current web logs are collecting AGF data and can be used in a new Profile.


TRACKING CODE OPTIONS


You can add advanced tracking features to the Tracking Code Reference, such as:
  • Usernames
  • Custom Variables (UDV)
  • Virtual Pageviews

USERNAMES - agf.setUsername(options);

Assigns a username to the current visitor.  The username is added to the agf.gif request with a parameter of 'un'.  Use the variable that stores the username in the code reference.

The .sppfx files used to track SharePoint Online contain this method.

Example:

<script type="text/javascript" src="/angelfish.js"></script>
<script type="text/javascript">
  agf.setUsername('userOne')
  agf.pageview();
</script>


CUSTOM VARIABLE (UDV) - agf.setUserDefined(options);

Sets a Visit-level variable for the Visitor.  UDV = User-Defined Variable.  

The UDV is more commonly assigned via a Filter during processing, but can also be assigned in the code reference.

Example:

<script type="text/javascript" src="/angelfish.js"></script>
<script type="text/javascript">
  agf.setUserDefined('customer');
  agf.pageview();
</script>


VIRTUAL PAGEVIEWS

An agf.gif request is sent each time a Page loads - the request is initiated by the agf.pageview() method in the code reference.  

You can call the agf.pageview() method at any time to track activity that doesn't reload the Page, like button clicks, form field selections, or single page app interactions.  Tracking for these kinds of activities is called Virtual Pageviews: the data shows up in the Page reports, but the Pages don't actually exist on the website.

For example: the Link Tagger feature in angelfish.js uses Virtual Pageviews to track clicks on outbound links.  Clicking an outbound link takes a Visitor away from the website and doesn't reload the Page. In this case, the Virtual Pageview identifies that the Visitor clicked an outbound link.

The method agf.pageview(); accepts 2 options (neither is required)
  • Page: The page (stem & query) to track. Default value: current Page
  • Title: The page title to track. Default value: current Page Title

Syntax:
agf.pageview({page:'<page path>', title:'<page title>'})

Examples:

Virtual pageview for a click on a contact form button
  • Add the following code to the button's tag:
onClick="agf.pageview({page:'/vt/button/contact-form', title:'contact form button click'})"
  • The reports will show a Pageview for /vt/button/contact-form each time the button is clicked

Virtual pageview for a click on an outbound link
  • Add the following to the link's anchor tag:
onClick="agf.pageview({page:'/outgoing/urchintools.com', title:'outbound-urchintools.com'})"
  • The reports will show a Pageview for /outgoing/urchintools.com each time the button is clicked