|
126 | 126 | configCustomUrl,
|
127 | 127 |
|
128 | 128 | // Document title
|
129 |
| - configTitle = documentAlias.title, |
| 129 | + lastDocumentTitle = documentAlias.title, |
| 130 | + |
| 131 | + // Custom title |
| 132 | + lastConfigTitle, |
130 | 133 |
|
131 | 134 | // Maximum delay to wait for web bug image to be fetched (in milliseconds)
|
132 | 135 | configTrackerPause = argmap.hasOwnProperty('pageUnloadTimer') ? argmap.pageUnloadTimer : 500,
|
|
854 | 857 | */
|
855 | 858 | function logPageView(customTitle, context, contextCallback) {
|
856 | 859 |
|
857 |
| - // Fixup page title. We'll pass this to logPagePing too. |
858 |
| - var pageTitle = helpers.fixupTitle(customTitle || configTitle); |
859 |
| - |
860 | 860 | refreshUrl();
|
861 | 861 |
|
| 862 | + // So we know what document.title was at the time of trackPageView |
| 863 | + lastDocumentTitle = documentAlias.title; |
| 864 | + lastConfigTitle = customTitle; |
| 865 | + |
| 866 | + // Fixup page title |
| 867 | + var pageTitle = helpers.fixupTitle(lastConfigTitle || lastDocumentTitle); |
| 868 | + |
862 | 869 | // Log page view
|
863 | 870 | core.trackPageView(
|
864 | 871 | purify(configCustomUrl || locationHrefAlias),
|
|
900 | 907 | if ((lastActivityTime + configHeartBeatTimer) > now.getTime()) {
|
901 | 908 | // Send ping if minimum visit time has elapsed
|
902 | 909 | if (configMinimumVisitTime < now.getTime()) {
|
903 |
| - logPagePing(pageTitle, finalizeContexts(context, contextCallback)); // Grab the min/max globals |
| 910 | + logPagePing(finalizeContexts(context, contextCallback)); // Grab the min/max globals |
904 | 911 | }
|
905 | 912 | }
|
906 | 913 | }, configHeartBeatTimer);
|
|
913 | 920 | * Not part of the public API - only called from
|
914 | 921 | * logPageView() above.
|
915 | 922 | *
|
916 |
| - * @param string pageTitle The page title to attach to this page ping |
917 | 923 | * @param object context Custom context relating to the event
|
918 | 924 | */
|
919 |
| - function logPagePing(pageTitle, context) { |
| 925 | + function logPagePing(context) { |
920 | 926 | refreshUrl();
|
| 927 | + newDocumentTitle = documentAlias.title; |
| 928 | + if (newDocumentTitle !== lastDocumentTitle) { |
| 929 | + lastDocumentTitle = newDocumentTitle; |
| 930 | + lastConfigTitle = null; |
| 931 | + } |
921 | 932 | core.trackPagePing(
|
922 | 933 | purify(configCustomUrl || locationHrefAlias),
|
923 |
| - pageTitle, |
| 934 | + helpers.fixupTitle(lastConfigTitle || lastDocumentTitle), |
924 | 935 | purify(customReferrer || configReferrerUrl),
|
925 | 936 | cleanOffset(minXOffset),
|
926 | 937 | cleanOffset(maxXOffset),
|
|
994 | 1005 | prefix = prefixes[i];
|
995 | 1006 |
|
996 | 1007 | // does this browser support the page visibility API?
|
997 |
| - if (Object.prototype.hasOwnProperty.call(documentAlias, prefixPropertyName(prefix, 'hidden'))) { |
| 1008 | + if (documentAlias[prefixPropertyName(prefix, 'hidden')]) { |
998 | 1009 | // if pre-rendered, then defer callback until page visibility changes
|
999 | 1010 | if (documentAlias[prefixPropertyName(prefix, 'visibilityState')] === 'prerender') {
|
1000 | 1011 | isPreRendered = true;
|
|
1111 | 1122 | * @param string title
|
1112 | 1123 | */
|
1113 | 1124 | setDocumentTitle: function (title) {
|
1114 |
| - configTitle = title; |
| 1125 | + // So we know what document.title was at the time of trackPageView |
| 1126 | + lastDocumentTitle = documentAlias.title; |
| 1127 | + lastConfigTitle = title; |
1115 | 1128 | },
|
1116 | 1129 |
|
1117 | 1130 | /**
|
|
0 commit comments