Last active
May 13, 2020 18:10
-
-
Save PhilJ/e1e6a128bf0c6e760650c37da7c90754 to your computer and use it in GitHub Desktop.
Copy Google Analytic Speed Data for Buckets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Returns labels (column names) matching the result list of prepareSpreadsheetRow() below | |
function getBucketColumns () { | |
// select els of main bucket labels | |
var mainColumnEls = document.querySelectorAll('._GAOKb._GAznb ._GAlIb'); | |
// select els of detail bucket labels | |
var detailColumnEls = document.querySelectorAll('.C_ADVANCEDHISTOGRAMTABLE_SUBBUCKET_GROUP ._GAlIb'); | |
var columnNames = ["Start Date", "End Date", "Avg Load Time", "No of samples"]; | |
mainColumnEls.forEach(function (e) { | |
columnNames.push(e.innerText); | |
}); | |
detailColumnEls.forEach(function (e) { | |
columnNames.push(e.innerText); | |
}); | |
return columnNames; | |
} | |
getBucketColumns().join(";"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getWebSpeedTestResults () { | |
var columns = []; | |
columns.push( document.querySelector('#fvFullyLoaded').innerText ); // First view: load time | |
columns.push( document.querySelector('#fvStartRender').innerText ); // First view: start render (earlier: first contentful paint) | |
columns.push( document.querySelector('#fvLastPaintedHero').innerText ); // First view: last painted hero | |
columns.push( document.querySelector('#fvDocComplete').innerText ); // First view: Document complete | |
columns.push( document.querySelector('#fvRequests').innerText ); // First view: no of request | |
columns.push( document.querySelector('#fvBytesIn').innerText ); // First view: volumne | |
columns.push( document.querySelector('#rvFullyLoaded').innerText ); // Second view load time | |
columns.push( document.querySelector('#rvStartRender').innerText ); // Second view: first contentful paint | |
columns.push( document.querySelector('#rvLastPaintedHero').innerText ); // Second view: last painted hero | |
columns.push( document.querySelector('#rvDocComplete').innerText ); // Second view: Document complete | |
columns.push( document.querySelector('#rvRequests').innerText ); // Second view: no of request | |
columns.push( document.querySelector('#rvBytesIn').innerText ); // Second view: volumne | |
return columns; | |
} | |
getWebSpeedTestResults().join(";"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Returns main bucket results | |
function getBucketResults () { | |
var percentageEl = document.querySelectorAll('._GAZKb._GAznb ._GAvLb'); | |
var loadingTimes = []; | |
percentageEl.forEach(function (e) { | |
var cellContent = e.innerText; | |
var value = cellContent.split(/\s/)[0]; | |
loadingTimes.push(value); | |
}); | |
return loadingTimes; | |
} | |
// Returns bucket detail results | |
function getBucketDetailResults () { | |
var percentageEl = document.querySelectorAll('.C_ADVANCEDHISTOGRAMTABLE_SUBBUCKET_GROUP ._GAvLb'); | |
var loadingTimes = []; | |
percentageEl.forEach(function (e) { | |
var cellContent = e.innerText; | |
var value = cellContent.split(/\s/)[0]; | |
loadingTimes.push(value); | |
}); | |
return loadingTimes; | |
} | |
// Prepares spreadsheet data (start date, end date, avg load time, no of samples, detail data | |
function prepareSpreadsheetRow () { | |
var columns = []; | |
columns.push( document.querySelector('._GAmC').innerText ); // start date | |
columns.push( document.querySelector('._GAaC').innerText ); // end date | |
columns.push( document.querySelector('._GAQLb.ID-0-0 ._GAaYb').innerText ); // average load time | |
columns.push( document.querySelector('._GAQLb.ID-2-0 ._GAaYb').innerText ); // samples | |
var bucketResults = getBucketResults(); | |
var bucketDetailResults = getBucketDetailResults(); | |
return columns.concat(bucketResults).concat(bucketDetailResults); | |
} | |
prepareSpreadsheetRow().join(";"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Function is supposed to toggle the bucket details to show all rows | |
However it does work very well due to async data loading | |
*/ | |
function toggleBucketDetails () { | |
var toggleEls = document.querySelectorAll(".ACTION-toggle._GAnw"); | |
toggleEls.forEach(function (e) { | |
e.click(); | |
}); | |
} | |
toggleBucketDetails(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment