CFLib.org – Common Function Library Project

hasDoNotTrackHeader()

Last updated December 4, 2013

author

Indy Griffiths

Version: 1 | Requires: CF9 | Library: CFMLLib

Description:
This UDF will return true if the user has opted out of tracking via the Do Not Track header. The "Do Not Track" HTTP header is a privacy option provided by some browsers indicating that the user has opted out of tracking (such as analytics or behavioural advertising).

Return Values:
Returns a boolean indicating if the header was found and set to 1

Example:

<cfif NOT hasDoNotTrackHeader()>
	<!--- Analytics code goes here --->
</cfif>

Parameters:

No arguments.

Full UDF Source:

/**
 * Support for the &quot;Do Not Track&quot; HTTP header
 * v1.0 by Indy Griffiths
 * v1.1 by Adam Cameron slight performance optimisation and rename
 * 
 * @return Returns a boolean indicating if the header was found and set to 1 
 * @author Indy Griffiths (indy@indygriffiths.com) 
 * @version 1.1, December 4, 2013 
 */
function hasDoNotTrackHeader() {
	var requestHeaders = getHttpRequestData().headers;
	return structKeyExists(requestHeaders, "DNT") && requestHeaders.DNT == 1;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson