java.lang.Object
com.aoapps.html.util.GoogleAnalytics
Writes various versions of Google Analytics tracking scripts.
- Author:
- AO Industries, Inc.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
writeAnalyticsJs
(AnyScriptSupportingContent<?, ?> content, String trackingId) Deprecated.static void
writeGlobalSiteTag
(AnyUnion_Metadata_Phrasing<?, ?> content, String trackingId) Writes the modern Google Analytics Global Site Tag.static void
writeScriptByDoctype
(AnyUnion_Metadata_Phrasing<?, ?> content, String trackingId) CallswriteGlobalSiteTag(com.aoapps.html.any.AnyUnion_Metadata_Phrasing, java.lang.String)
forDoctype.HTML5
, or callswriteAnalyticsJs(com.aoapps.html.any.AnyScriptSupportingContent, java.lang.String)
for all other doctypes.
-
Method Details
-
writeGlobalSiteTag
public static void writeGlobalSiteTag(AnyUnion_Metadata_Phrasing<?, ?> content, String trackingId) throws IOExceptionWrites the modern Google Analytics Global Site Tag. This is best used withDoctype.HTML5
. This should be added first, or very high up, in the<head>
.- Parameters:
trackingId
- No script will be written whennull
or empty (after trimming)- Throws:
IOException
-
writeAnalyticsJs
@Deprecated public static void writeAnalyticsJs(AnyScriptSupportingContent<?, ?> content, String trackingId) throws IOExceptionDeprecated.All sites should be HTML 5 now, please usewriteGlobalSiteTag(com.aoapps.html.any.AnyUnion_Metadata_Phrasing, java.lang.String)
.Writes an older-style Google Analytics analytics.js tracking script. This is best used for compatibility with doctypes prior toDoctype.HTML5
. This should be added first, or very high up, in the<head>
.- Parameters:
trackingId
- No script will be written whennull
or empty (after trimming)- Throws:
IOException
-
writeScriptByDoctype
public static void writeScriptByDoctype(AnyUnion_Metadata_Phrasing<?, ?> content, String trackingId) throws IOExceptionCallswriteGlobalSiteTag(com.aoapps.html.any.AnyUnion_Metadata_Phrasing, java.lang.String)
forDoctype.HTML5
, or callswriteAnalyticsJs(com.aoapps.html.any.AnyScriptSupportingContent, java.lang.String)
for all other doctypes. This should be added first, or very high up, in the<head>
.- Parameters:
trackingId
- No script will be written whennull
or empty (after trimming)- Throws:
IOException
-
writeGlobalSiteTag(com.aoapps.html.any.AnyUnion_Metadata_Phrasing, java.lang.String)
.