How to add separate google analytics code for each store?
Here’s it, just 3 files need to be modified:
-
admin\controller\setting\store.php
After “$this->data[‘entry_secure’] = $this->language->get(‘entry_secure’);” add:
$this->data['entry_google_analytics'] = $this->language->get('entry_google_analytics');Before “$this->template = ‘setting/store_form.tpl’;” add:
if (isset($this->request->post['config_google_analytics'])) {
$this->data['config_google_analytics'] = $this->request->post['config_google_analytics'];
} elseif (isset($store_info['config_google_analytics'])) {
$this->data['config_google_analytics'] = $store_info['config_google_analytics'];
} else {
$this->data['config_google_analytics'] = '';
} -
admin\language\english\setting\store.php
Add:$_['entry_google_analytics'] = 'Google Analytics Code:<br /><span class="help">Login to your <a href="http://www.google.com/analytics/" target="_blank"><u>Google Analytics</u></a> account and after creating your web site profile copy and paste the analytics code into this field.</span>'; -
admin\view\template\setting\store_form.tpl
Inside the div with id=”tab-server” add:<tr>
<td><?php echo $entry_google_analytics; ?></td>
<td>
<textarea name="config_google_analytics" cols="40" rows="5"><?php echo $config_google_analytics; ?></textarea>
</td>
</tr>
Now go to settings and add google analytics code in the “Server” tab of your store.
Happy Coding 😀 !!
I have a module to opencart, http://oficinadopixel.com.br/trackeando-seu-opencart-com-o-google-analytics. Have tracking and send orders to Google analytics, is free too 🙂
LikeLike
Thanks for your share !
LikeLike
if i paste the code in settings system . which file does it go in
LikeLike
Please find the filenames in bold letters.
LikeLike