Send an event to Google Analytics

The “Send an event” to Google Analytics (v4) node facilitates sending events from Synerise to Google Analytics.

Prerequisites


  • Create an API secret in your Google Analytics panel. To create a new secret, navigate to Admin > Data Streams > {stream name} > Measurement Protocol > Create.
  • Get the measurement ID associated with a stream in your Google Analytics panel. Navigate to Admin > Data Streams > {stream name} > Measurement ID.
  • Enable saving Google Analytics ID in profiles

Node configuration


In this part of the process, you can create a workflow that contains the Send an event node. This node allows you to send an event to Google Analytics with the data defined in this node. In the settings of the integration, you will use the value of cid attribute as a customer identifier.

If you haven’t saved Google Analytics IDs in profiles, see Getting the customer ID from Google Analytics

  1. Click the node.
  2. Click Select connection.
  3. From the dropdown list, select the connection.
    If you haven’t established a connection yet, see Establish connection.

Establish connection

To allow the data exchange, establish the connection between Synerise and Google Analytics.

  1. At the bottom of the Select connection dropdown list, click Add connection.
  2. In the Measurement ID field, enter the ID you retrieved as a part of prerequisites.
  3. In the API secret field, enter the API secret you created as a part of prerequisites.
  4. Click Next.
  5. In the Connection name field, enter the name for the access token you generated.
  6. Click Apply.
    Result: A connection is created and selected.

Define the integration settings

In this step, fill in the form that allows you to send an event from Synerise to Google Analytics.

  1. In the Customer ID field, enter {{ customer['cid'] }}. This way, you will retrieve the value of the cid attribute.
  2. In the Event name field, enter the name of the event you want to send to Google Analytics.
    • You don’t have to use an existing event.
    • We recommend using the event nomenclature consistent with the Synerise events (such as page.visit, message.send, and so on).
    • The event you send within this node won’t be added to the list of events in Synerise.
  3. In the Event parameters field, enter parameters of the event in the form of the JSON object.
    Tip: Refer to the Google Analytics documentation for the event requirements.
  4. Confirm the settings by clicking Apply.

Getting the customer ID from Google Analytics


To send events from Synerise to Google Analytics, you must use the customer identifier generated by Google Analytics. It is stored on the website in the _ga cookie. You need to retrieve this ID from the cookie and save it as a custom attribute (cid) of a Synerise profile.

You can do this by using dynamic content as a tag manager. The dynamic content will contain the Javascript code that sets the cookie value as the value of the cid attribute in Synerise.

  1. In Synerise, go to Communication > Dynamic content > Create new.
  2. As the dynamic content type, select Insert object.
  3. In the Audience section, leave the settings at default (Everyone).
  4. Confirm by clicking Apply.
  5. In the Content section:
    1. Leave the content type at Simple message.

    2. Set the CSS selector to Before (in div).

    3. In the text field, enter .snrs-modal-wrapper

    4. Click Create message > Code editor.

    5. In the JS section, paste the following code snippet.

      (function() {
                  var analyticsCookie = document.cookie.match(/_ga=(.+?)(;|$)/)
                  var currentCid = "{% if client.cid %}{{ customer.cid}}{% else %}null{% endif %}"
                  if (analyticsCookie && analyticsCookie[1].split('.').slice(-2).join(".") != currentCid) {
      
                      SR.event.sendFormData('GA_id', {
                          "cid": analyticsCookie[1].split('.').slice(-2).join(".")
                      })
                  }
      
      
      
              })()
              
      
    6. Click Next.
      Result: You leave the code editor and go back to the dynamic content settings.

    7. Confirm by clicking Apply.

  6. In the Schedule section:
    1. Select Display immediately.
    2. Expand Advanced options.
    3. Select Display every hour every day.
    4. Confirm by clicking Apply.
  7. In the Display settings section:
    1. Leave Triggers at default (On landing).
    2. Leave Pages at default (All pages).
    3. Set Frequency to Once per visit.
    4. Leave Stop display at default (Never).
    5. In Devices, select desktop and mobile.
    6. Leave View count capacity empty.
    7. Confirm by clicking Apply.
  8. In the UTM & URL parameters section, click Skip this step.
  9. In the top right corner, click Activate.
    Results: A tag is initialized on all pages for all users (both recognized and unrecognized). It retrieves the current value of the _ga cookie and sets its identifier value as the cid attribute.
    The dynamic content configuration of the matching pixel
    The dynamic content configuration of the matching pixel

Example of use


For example of use, refer to the use case that describes sending the score of RFM analysis to Google Analytics.

😕

We are sorry to hear that

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

😉

Awesome!

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

Close modal icon Placeholder alt for modal to satisfy link checker