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