google analytics events


This page is intended for integrators with a minimum knowledge of HTML, CSS, XML, XSL, I18N.
You must have read Plugin Newsletter - Graphic integration - v1.6.0

Presentation

Newsletter statistics can be obtained via Google Analytics. The following events are tracked:

  • Sending: when a newsletter is validated, an event is generated for each e-mail sent.
  • Opening: when a user views the e-mail of a newsletter, an event is generated.
  • Clicking on a link: clicks on newsletter links to a site page are integrated into a Google Analytics "campaign".

Integration

The sending event doesn't require any special integration; it's managed by the e-mail sending engine, outside the graphic charter.

L'intégration des deux autres événements se fait dans le gabarit de la newsletter, dans le fichier skins/<myskin>/newsletter/<template>/stylesheets/template.xsl. Un exemple de ce gabarit se trouve dans la charte de démonstration, accessible à l'adresse suivante : http://viewvc.ametys.org/viewvc/trunk/templates/cmsweb/trunk/webapp/cms/skins/demo/newsletter/default/stylesheets/template.xsl

The stylesheet stylesheets/ga-newsletter.xsl in plugin newsletter provides templates XSL that can be called to set up event dispatch. To include it in the template, place the following instruction in the header of the template file.xsl:

<xsl:include href="plugin:newsletter://stylesheets/ga-newsletter.xsl" />

The following parameters are passed to the XSL template (but must still be declared as xsl:param):

  • categoryTitle: the category title
  • title: newsletter title
  • number: newsletter number (can be empty if the "number" field in the content is not filled in)
  • date: the date of the newsletter in yyyy-MM-dd format (may be empty if the "date" content field is not filled in)

Opening

To generate an event when the newsletter is opened, you need to call the following template (defined in the ga-newsletter.xsl file):

<xsl:call-template name="google-analytics-newsletter">
    <xsl:with-param name="categoryTitle" select="$categoryTitle"/>
    <xsl:with-param name="title" select="$title"/>
    <xsl:with-param name="number" select="$number"/>
    <xsl:with-param name="date" select="$date"/>
</xsl:call-template>

Ce template crée une balise <img> dont la source se trouve sur les serveurs de Google. Quand l'utilisateur visualise la newsletter, un événement Google Analytics est généré, ayant les propriétés suivantes :

  • Category: "Newsletters / Title of the category
  • Action: "Open"
  • Label: "Title / Number / Date" where Title, Number and Date are the newsletter fields.

Le template "google-analytics-newsletter" ne génère la balise <img> que si le paramètre de site "Suivi des lettres d'information" est activé et que le paramètre de site "ID de site web Google" est renseigné.

Links

When the ga-newsletter.xsl file is included, links to site pages are identified in Google Analytics as coming from the newsletter.

When the user clicks on a link in the newsletter, the click is taken into account in the Google Analytics "traffic sources" with the following properties:

  • Campaign: "Newsletters / Category title".
  • Support: email
  • Source: "Title / Number / Date" where Title, Number and Date are the newsletter fields.

Google Analytics must be integrated into the site for tracking to be effective.

Back to top

Newsletter