Skip to content

Instantly share code, notes, and snippets.

@fIa5h
Created January 4, 2018 01:18
Show Gist options
  • Save fIa5h/05446cd730c96892684e2f33a2755f9a to your computer and use it in GitHub Desktop.
Save fIa5h/05446cd730c96892684e2f33a2755f9a to your computer and use it in GitHub Desktop.
Custom instrumentation to record strict, direct funnels within New Relic Insights
//instantiate globally
//below is the global array where we'll record the last 6 steps
window.NewRelicDirectFunnelArray = ["", "", "", "", "", ""];
//and the function we'll use to manage the data structure
window.NewRelicDirectFunnelFunction = function(pageActionName){
//capture a delimited string containing the last 6 pageActions since the initial pageload
var previousSixPageActionsString = window.NewRelicDirectFunnelArray.join("||");
//dequeue the oldest pageAction value out of the queue
window.NewRelicDirectFunnelArray.shift();
//push the newest pageAction value into the queue
window.NewRelicDirectFunnelArray.push(pageActionName);
//return the delimited pageAction path value
return { "previousPageActionPath" : previousSixPageActionsString };
};
//
//
//then, you may instantiate within your code similar to this
/*
newrelic.addPageAction( pageActionName , window.NewRelicDirectFunnelFunction(pageActionName) );
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment