- Change the variable
googleAnalytics
value to your preferred analytics profile. - copy the entire script and put it in a new bookmark
- ????
- PROFIT
Last active
January 3, 2016 23:49
-
-
Save Reedyn/8537117 to your computer and use it in GitHub Desktop.
JavaScript for opening Google Analytics with the last 7 days selected (not including today)
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
javascript: (function () { | |
var pages = { | |
dashboard: "#dashboard/eChzdEEBTFKu_c0u-nsdTg", | |
visitors: "#report/visitors-overview", | |
location: "#report/visitors-geo/", | |
}; | |
var googleAnalytics = "a28736903w54575155p55522219"; | |
var theDate = new Date(); | |
var theYear = new String(theDate.getFullYear()); | |
var theMonth = new String(theDate.getMonth() + 1); | |
var theDate = new String(theDate.getDate()); | |
if (theMonth < 10) theMonth = "0" + theMonth; | |
if (theDate < 10) theDate = "0" + theDate; | |
var today = theYear + theMonth + theDate - 1; | |
var last_week = (theYear + theMonth + theDate) - 8; | |
var google_url = "https://www.google.com/analytics/web/" + pages["dashboard"] + "/" + googleAnalytics + "/" + "%3F_u.date00%3D" + last_week + "%26_u.date01%3D" + today + "/"; | |
window.open(google_url, "new_window"); | |
})(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment