Comments

philbar’s picture

I added the following to line 239 of Google Analytics 6.x-3.3

    $script .= '_gaq.push(["_trackPageLoadTime"]);';

Right after...

     else {
      $script .= '_gaq.push(["_trackPageview", ' . $url_custom . ']);';
    }

Probably should make this a checkbox option to configure in the GA settings since Google is making it optional (i.e. check here for Page Load Time Tracking).

wiifm’s picture

Definitely would be keen to see this as an optional tickbox (ticked by default), anyone keen to have a stab at this?

zwoop’s picture

Well, it's not pretty, but this seems to do it:

diff --git a/googleanalytics.admin.inc b/googleanalytics.admin.inc
index 5485db2..968d96c 100644
--- a/googleanalytics.admin.inc
+++ b/googleanalytics.admin.inc
@@ -181,6 +181,20 @@ function googleanalytics_admin_settings_form(&$form_state) {
     '#description' => t('By default outbound links are tracked as <em>Events</em>. In rare situations like tracking of <em>Goals</em> it may be required to track outbound clicks as page views.'),
   );
 
+  // What to track?
+  $form['trackfeatures'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Tracking features'),
+    '#collapsible' => TRUE,
+    '#collapsed' => FALSE,
+  );
+  $form['trackfeatures']['googleanalytics_trackpageloadtime'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Track page-load times'),
+    '#default_value' => variable_get('googleanalytics_trackpageloadtime', 1),
+    '#description' => t('Enables tracking of page-load times.')
+  );
+
   // Privacy specific configurations.
   $form['tracking']['privacy'] = array(
     '#type' => 'fieldset',
diff --git a/googleanalytics.module b/googleanalytics.module
index 4a86e32..ec38d81 100644
--- a/googleanalytics.module
+++ b/googleanalytics.module
@@ -236,6 +236,11 @@ function googleanalytics_footer($main = 0) {
     else {
       $script .= '_gaq.push(["_trackPageview", ' . $url_custom . ']);';
     }
+
+    if (variable_get('googleanalytics_trackpageloadtime', 1)) {
+      $script .= '_gaq.push(["_trackPageLoadTime"]);';
+    }
+
     if (!empty($codesnippet_after)) {
       $script .= $codesnippet_after;
     }

Caveat: I'm not a PHP programmer :).

zwoop’s picture

I think though that the default probably should be "off".

dropiopio’s picture

Version: 6.x-3.x-dev » 7.x-1.x-dev

hope to see this also in d7

NPC’s picture

Hm, I thought it would be enough to insert this snippet in Advanced settings / Custom JavaScript code / Code snippet (after), but it doesn't seem to affect the script on my pages (flushed all caches, and loaded the page while logged out of Drupal). Perhaps I misunderstand what that field is for?

The snippet I inserted is:
_gaq.push(['_trackPageLoadTime']);

hass’s picture

#6 is the way to go (and correct) for now. No need to hack the modules code. You may need to clear your caches.

NPC’s picture

@hass, as I wrote, I did clear my caches, so I'd like to know if anyone got it working the same way that I tried.

UPDATE: Sorry, tried in a different browser, and it works now. So you need to make sure to clear the browser cache too.

obrienmd’s picture

subscribe

hass’s picture

We should not enable this by default because of

Be aware that enabling Site Speed tracking for your site results in an extra request made to the Google Analytics servers, separate from the page tracking GIF request made for pageviews. To minimize impact on overall site latency, this request is sent only on a sampling of pageviews to your site. For this reason, you might not always see the site speed GIF request when attempting to debug this feature in Firebug or other tools. This is normal and expected.

BradleyT’s picture

#6 is working for GA module version 6.x-3.2 however it's not recording any speeds for firefox users. This may be a bug with GA reporting though - anyone else showing time for FF users?

silkogelman’s picture

Thanks for the #6 suggestion NPC!
It's a perfect bridging solution untill 'the sitespeed checkbox' is committed.

For BradleyT at #11: just enabled the script (in 6.x-3.1) , I'll let you know if it tracks Firefox users.

real_ate’s picture

subscribe

gordon’s picture

subscribe

el_reverend’s picture

subscribe

firebus’s picture

Status: Needs work » Needs review
StatusFileSize
new1.41 KB

I've updated the diff in #3 s.t. the default is to not track page load time, diff is against 7.x-1.x head. If some of the subscribers could test and set status to "Reviewed & Tested" that would be great!

firebus’s picture

created a 6.x-3.x backport issue for this as well #1157188: Page Load Tracking 6.x-3.x backport if anyone needs this for D6 (looks like the patch in #3 was a D6 patch actually!)

hass’s picture

Status: Active » Needs work

Uninstall is missing and admin.js code, too and maybe more.

NPC’s picture

What I posted in #6 is not a patch, it is a way to do this through the module configuration page, without hacking the code. And I am doing that on D6, yes.

By the way, it does seem to lean into Chrome in my case - out of 3.500 pageviews there were 59 page load samples, out of which 58 are Chrome, and 1 is IE. Odd, that. I wish there was a way to raise the number of samples in general, at least temporarily, since for low-traffic sites 2% of pageviews is not enough to get a good average.

firebus’s picture

Status: Needs review » Needs work
StatusFileSize
new1.97 KB

NPC: sorry, i misspoke. meant #3, not #6. i've edited my earlier comments to reflect this.

hass: thank you for the feedback, here's an updated patch that removes the variable on uninstall.

the trackpageloadtime setting isn't part of the "tracking scope" vertical tab set, so i don't think there's anything to do in admin.js.

all of the tracking scope sub-tabs determine whether or not the gs code is included on a given request, based on page, user, role, etc.

trackpageloadtime isn't about whether or not the tracking code appears, but rather about what the tracking code consists of when it *is* displayed.

so i don't think that trackpageloadtime belongs in the vertical tab set.

it might make sense to combine trackpageloadtime and "custom variables" into a single "tracking features" vertical tabset, in which case it would make sense to extend admin.js as well.

please let me know what you think, or if anything else is missing.

firebus’s picture

Status: Needs work » Needs review
chriscalip’s picture

Tested and installed on about 7 live sites on google_analytics 6.x-3.x
Although the patch @ comment#20 does not fit on google_analytics 6.x-3.x

chriscalip’s picture

I had to generate a different patch for the 6.x-3.x branch, because its not the same patch although it's the same case.
For one branch 6.x-3.x does the actual deed in hook_footer while the 7.x branch does on a hook_page_alter

Do i open the issue http://drupal.org/node/1157188 ?

firebus’s picture

i think the patch workflow is that the patch needs to be tested, and accepted, on 7.x, and then the ticket can be moved into a 6.x backport.

i'm not sure there's anything wrong with providing a D6 patch here in advance, but you should suffix it "-D6.patch" so that it doesn't get sent to the automated testing system (see the help notes under the "attach new file" field.)

chriscalip’s picture

Roger that. attach patch file with -d6 tag

Status: Needs review » Needs work

The last submitted patch, page_load_tracking_for_6_3_x-1147322-23.patch, failed testing.

chriscalip’s picture

Status: Needs work » Needs review

yikes yeah my d6 patch screwed up this issue. changing it back to needs review from needs work because of my mistake.

hass’s picture

Assigned: firebus » Unassigned
Status: Needs review » Needs work
Issue tags: -Needs backport to D6

I suggest to add this to the advanced settings. At least - we should not add another new fieldset with only one checkbox.

firebus’s picture

Assigned: Unassigned » firebus
Issue tags: +Needs backport to D6
StatusFileSize
new1.93 KB

sounds good. here is a reroll with the checkbox added to "advanced settings". i also added a link to the GA documentation of page load time in the description of the checkbox.

vacilando’s picture

Assigned: Unassigned » firebus
Status: Needs work » Needs review
Issue tags: +Needs backport to D6

Subscribing.

deverman’s picture

Subscribing

hass’s picture

Title: Page Load Tracking » Add Site Speed report support
Status: Needs review » Fixed
Issue tags: -Needs backport to D6

Committed to D7 and D6. Changed wording of description and title to Site Speed as named on Google pages.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

achton’s picture

Status: Needs work » Closed (fixed)
hass’s picture

Status: Closed (fixed) » Needs work

Thx for your note. Let's roll back the patch.

hass’s picture

Status: Closed (fixed) » Fixed

Rolled back and added googleanalytics_trackpageloadtime variable delete.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

aufumy’s picture

Version: 7.x-1.x-dev » 6.x-3.3
Status: Closed (fixed) » Needs review
StatusFileSize
new2.25 KB

If the site get less than 1million visits per day, may need to tweak the sample size to view site speed reports.

http://code.google.com/apis/analytics/docs/gaJS/gaJSApiBasicConfiguratio...

hass’s picture

Version: 6.x-3.3 » 7.x-1.x-dev
Status: Needs review » Closed (fixed)

Add the one line to custom code snippets, please.