4

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?

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 @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.

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?

  • 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. – Rick Cohen Apr 20 '16 at 17:26
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();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.