AFL UTM Tracker Documentation

  1. Home
  2. Docs
  3. AFL UTM Tracker Documentation
  4. Misc / Issues
  5. Tracking UTM on Custom WordPress Page Template

Tracking UTM on Custom WordPress Page Template

If you have noticed that our UTM cookies are not being generated on your WordPress page, it might be because your WordPress page template does not call the standard theme functions like get_header(), wp_head(), get_footer() or wp_footer().

What are wp_head() and wp_footer()?

The functions allows plugins to automatically include their CSS and JavaScript files to the page template.

What is the issue?

Some custom theme developers do not use the standard theme functions above because they want to fully control the execution of the CSS and JavaScript files on the page.

However by doing so, theme developers would have to manually load each plugin assets (CSS / JS files) manually on to the page.

Solution

Therefore to to track UTM parameters on custom WordPress page template which does not use the standard theme functions, there are 2 lines of code which you can implement in your PHP page template file.

Requirements:

  • AFL UTM Tracker version 2.5.2 and above.

Manually load our JS file

1. Output our JavaScript variable

<?php AFL_WC_UTM_PUBLIC::print_js_tracking_variable(); ?>

2. Load our JavaScript tracking file

<?php AFL_WC_UTM_PUBLIC::print_js_tracking_file(); ?>

Sample Code