move tracking code to js file