Case Study: Medical School Uses Google’s Async Code to Provide Accurate and Flexible Tracking

Est. Reading Time: 3 minutes

Updating Website to Asynchronous Tracking Code from Traditional Tracking Code Follows Best Practices, Improves Site Performance, and Allows for Greater Flexibility in Code Installation.

Challenge: Client was re-launching website in a new format which offered

an opportunity to update the site’s existing traditional Google Analytics

snippet to the asynchronous tracking snippet. In addition to staying on

the cutting edge with Google’s best practices, this was done to improve

site speed and also produce more accurate results. This would also provide

Beacon some added flexibility in where the snippet could be placed and

still perform at optimal levels.

 

Business Solution: Previously the Google Analytics tracking code for the

client’s website was located before the closing <body> tag towards the end

of the page. This was considered an ideal location for this JavaScript snippet

because it gave the page an opportunity to load prior to firing. However, due

to the structure of the client’s website, this involved the code being included

in a number of template files in order to be consistently rendered across

every page. Any update to the code required changes to all of these files

which increased the potential for errors.

Google’s updates to the asynchronous tracking code offered a greater

flexibility than the traditional snippet. When the client re-launched its

site to a new Drupal format, this provided a great opportunity to upgrade

to the new code which could be placed in a universal header file and still

function with a greater accuracy than the previous version. From this point

forward, any changes made to the code could be made just once and would

be applied site-wide.

Changes to the actual code involved adjusting to the new format. The

traditional code used the pageTracker function for its tracking

operations. The new async. code is built around the gaq.push function.

Once these changes were made to the primary tracking snippet, the final

task was to go through the site’s pages and ensure than any virtual

pageviews or event tracking were updated to the new codes as well. These

represent instances where specialized tracking code snippets are inserted

at the point of action to display specific events in Google Analytics. Any

instance where this was previously tracked under the traditional snippet

was replaced. Beacon was able to conduct a global find and replace to work

more efficiently to minimize client hours used.

Results: The adjustments to the asynchronous snippet were made without

issue. The client also appreciated that the upgraded tracking code would

lead to quicker load times and better accuracy for their Google Analytics

data. The new site invested heavily in a number of flash elements, so load

time for all installed scripts was critical to ensure a high quality user

experience. In terms of accuracy, the client services students hailing from

all over the world. Having the most accurate data on segments from each

region helps to determine marketing strategy and financing for various

countries around the world.