public GoogleAnalyticPlugin(ISettingService settingService, GoogleAnalyticsSettings googleAnalyticsSettings, ILocalizationService localizationService) { this._settingService = settingService; this._googleAnalyticsSettings = googleAnalyticsSettings; _localizationService = localizationService; }
/// <summary> /// Install plugin /// </summary> public override void Install() { var settings = new GoogleAnalyticsSettings() { GoogleId = "UA-0000000-0", TrackingScript = @"<!-- Google code for Analytics tracking --> <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', '{GOOGLEID}', 'auto'); ga('send', 'pageview'); {ECOMMERCE} </script>", EcommerceScript = @" ga('require', 'ecommerce'); ga('ecommerce:addTransaction', { 'id': '{ORDERID}', 'affiliation': '{SITE}', 'revenue': '{TOTAL}', 'shipping': '{SHIP}', 'tax': '{TAX}', 'currency': '{CURRENCY}' }); {DETAILS} ga('ecommerce:send'); ", EcommerceDetailScript = @" ga('ecommerce:addItem', { 'id': '{ORDERID}', 'name': '{PRODUCTNAME}', 'sku': '{PRODUCTSKU}', 'category': '{CATEGORYNAME}', 'price': '{UNITPRICE}', 'quantity': '{QUANTITY}' }); ", }; _settingService.SaveSetting(settings); _localizationService.ImportPluginResourcesFromXml(this.PluginDescriptor); base.Install(); }