Created
September 24, 2015 14:52
-
-
Save chipoglesby/d5dd87e7e37fb4a04b76 to your computer and use it in GitHub Desktop.
Querying Google Analytics with Adwords Scripts
This file contains hidden or 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 main() { | |
| var profileId = 'xxxxxxx'; | |
| // Dates should be in yyyy-mm-dd format. | |
| var startDate = 'yesterday'; | |
| var endDate = 'today'; | |
| var options = { | |
| 'dimensions': 'ga:source,ga:keyword', | |
| 'sort': '-ga:sessions,ga:source', | |
| 'filters': 'ga:medium==organic', | |
| 'max-results': 25 | |
| }; | |
| var results = Analytics.Data.Ga.get('ga:' + profileId, startDate, | |
| endDate,'ga:sessions',options); | |
| Logger.log(results); | |
| Logger.log('Profile Name: %s', results.profileInfo.profileName); | |
| Logger.log('Source Name: %s', results.rows[0][0]+' & Total Sessions: '+ results.rows[0][2]); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment