Answers.Body: <p>This doesn't seem to be supported yet, but thanks for asking - giving voice to needs is how these things start!</p>
  
  <p>Currently CiviMail generates a URL like  <a href="http://dmaster.demo.civicrm.org/civicrm/mailing/view?reset=1&amp;id=10" rel="nofollow">http://dmaster.demo.civicrm.org/civicrm/mailing/view?reset=1&amp;id=10</a> which renders the mail as sent out (without site theme).</p>
  
  <p>First thought: look at using your existing site theme to include your tracking codes, and display your newsletter content wrapped in the default site theme. This might be possible by commenting out the <code>CRM_Utils_System ::civiExit()</code> line mentioned in @diegov's answer below, or by (eg) creating a Drupal View which displays the rendered Mailing content at a similar path but without skipping the site theme.</p>
  
  <p>Alternatively, a quick CiviCRM extension could detect the mail when viewed over the web and include your tracking codes?</p>
  
  <p>Both of these would require some work, so consider contributing the end result back to the community if you do take it from here! And if you can't, maybe post it as a feature request on issues.civicrm.org?</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-20T17:26:36.490Z
Answers.Text: Thanks for the suggestions. I'll need to tinker a bit to see what works best and I'll definitely share back if/when I find a good solution.
Answers.UserDisplayName: Rick Cohen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-18T23:45:34.970Z
Answers.LastActivityDate: 2016-04-19T17:55:41.810Z
Answers.LastEditDate: 2016-04-19T17:55:41.810Z
Answers.UserDisplayName: Chris Burgess
Answers.Body: <p>You could achieve this but, AFAIK, it would be needed to change a core PHP file do CiviCRM. This file would be <code>civicrm/CRM/Mailing/Page/View.php</code> and you should add a line inserting the Analytics call, something like that in the lines 193-195:</p>
  
  <pre><code>  print $content;
    echo 'Your Analytics code here';
    CRM_Utils_System::civiExit();
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-18T23:47:00.187Z
Answers.LastActivityDate: 2016-04-18T23:47:00.187Z
Answers.UserDisplayName: diegov
Body: <p>I'm guessing this isn't possible, but it never hurts to ask...</p>
  
  <p>We publish our newsletter using CiviMail and have the mailings publicly visible, then add links to the published version for people to access via our website and from social media. However, when people visit this web-based version of the newsletter, it doesn't show up in Google Analytics. Most of the other pages we make public through CiviCRM do show up because they load the full frame of our website, which includes the tracking script.</p>
  
  <p>I know how to add tokens to links to have them be tracked, but is there a way to add the tracking code that is embedded in website pages to the web-based version of the message? I imagine that adding the Google Analytics tracking script to the message itself would trigger spam filters. Is there a way to have code just in the web-based version of the messages, but not in the emailed version?</p>
  
Tags: <civimail>
Title: Embedding Google Analytics code on CiviMail message
ThreadText: # Embedding Google Analytics code on CiviMail message
  
  (Asked by: username_0 on 2016-04-18)
  
  I'm guessing this isn't possible, but it never hurts to ask...
  
  We publish our newsletter using CiviMail and have the mailings publicly visible, then add links to the published version for people to access via our website and from social media. However, when people visit this web-based version of the newsletter, it doesn't show up in Google Analytics. Most of the other pages we make public through CiviCRM do show up because they load the full frame of our website, which includes the tracking script.
  
  I know how to add tokens to links to have them be tracked, but is there a way to add the tracking code that is embedded in website pages to the web-based version of the message? I imagine that adding the Google Analytics tracking script to the message itself would trigger spam filters. Is there a way to have code just in the web-based version of the messages, but not in the emailed version?
  
  **Tags:** civimail
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2016-04-18. Score: 5
  
  This doesn't seem to be supported yet, but thanks for asking - giving voice to needs is how these things start!
  
  Currently CiviMail generates a URL like <http://dmaster.demo.civicrm.org/civicrm/mailing/view?reset=1&id=10> which renders the mail as sent out (without site theme).
  
  First thought: look at using your existing site theme to include your tracking codes, and display your newsletter content wrapped in the default site theme. This might be possible by commenting out the `CRM_Utils_System ::civiExit()` line mentioned in @username_2's answer below, or by (eg) creating a Drupal View which displays the rendered Mailing content at a similar path but without skipping the site theme.
  
  Alternatively, a quick CiviCRM extension could detect the mail when viewed over the web and include your tracking codes?
  
  Both of these would require some work, so consider contributing the end result back to the community if you do take it from here! And if you can't, maybe post it as a feature request on issues.civicrm.org?
  
  > **Comments:**
  > **username_0**: Thanks for the suggestions. I'll need to tinker a bit to see what works best and I'll definitely share back if/when I find a good solution.  
  
  ---
  
  ### Answer by username_2 on 2016-04-18. Score: 3
  
  You could achieve this but, AFAIK, it would be needed to change a core PHP file do CiviCRM. This file would be civicrm/CRM/Mailing/Page/View.php and you should add a line inserting the Analytics call, something like that in the lines 193-195:
    print $content;
    echo 'Your Analytics code here';
    CRM_Utils_System::civiExit();
  
  
  ---
  
  