googleanalytics.js
5 years ago
googleanalytics_createprop.js
5 years ago
googleanalytics_dashboard.js
9 years ago
googleanalytics_page.js
5 years ago
googleanalytics_createprop.js
36 lines
| 1 | ( |
| 2 | function ( $, wp ) { |
| 3 | $( document ).ready( function () { |
| 4 | var theData = JSON.stringify( { |
| 5 | onboarding_product: 'ga', |
| 6 | domain: gasiteURL, |
| 7 | email: gaAdminEmail, |
| 8 | is_wordpress: true |
| 9 | } ); |
| 10 | |
| 11 | $.ajax( { |
| 12 | url: 'https://platform-api.sharethis.com/v1.0/property', |
| 13 | method: 'POST', |
| 14 | async: false, |
| 15 | contentType: 'application/json; charset=utf-8', |
| 16 | data: theData, |
| 17 | success: function ( result ) { |
| 18 | setGACredentials( result.secret, result._id ); |
| 19 | } |
| 20 | } ); |
| 21 | } ); |
| 22 | |
| 23 | /** |
| 24 | * WP Ajax call to set prop id/secret |
| 25 | */ |
| 26 | function setGACredentials(secret, propid) { |
| 27 | wp.ajax.post( 'set_ga_credentials', { |
| 28 | secret: secret, |
| 29 | propid: propid, |
| 30 | nonce: gaNonce |
| 31 | } ).always( function( results ) { |
| 32 | }); |
| 33 | } |
| 34 | } |
| 35 | )( window.jQuery, window.wp ); |
| 36 |