How to Trigger Goals in Your Google Analytics account on Lightbox Display and Submit

Step 1

Login to your Digioh Account

Step 2

Select “Custom Javascript” in the drop down (you may not have access to this feature - please email support if you don’t see it in your drop down)

Step 3

In the "After Document Ready" section, copy and paste in the code below:

var is_universal = false;
var is_classic = false;

if (window.ga && window.ga.create) {
    DIGIOH_CUSTOM_JS.log('window.ga is defined - using Google Universal Analytics');
    is_universal = true;
} else {
    DIGIOH_CUSTOM_JS.log('window.ga is undefined');
}

if (window._gaq) {
	DIGIOH_CUSTOM_JS.log('window._gaq is defined - using Google Classic Analytics ID: ' + window._gaq._getAsyncTracker()._getAccount());
	is_classic = true;
} else {
	DIGIOH_CUSTOM_JS.log('window._gaq is undefined');
}

if (is_universal) {
    window.ga('send', 'event', 'Email Capture', 'Pageview', {nonInteraction': true});
    DIGIOH_CUSTOM_JS.log('ga sent event - Pageview');
    
    window.setTimeout(function() {
        window.ga(function() {
          var trackers = window.ga.getAll();
          trackers.forEach(function(tracker) {
            //console.log(tracker.get('name'));
            DIGIOH_CUSTOM_JS.log(tracker.get('trackingId'));
          });
        });
    }, 3000);
    
}

if (is_classic) {
    DIGIOH_CUSTOM_JS.log('_gaq docReady is_classic');
    window._gaq.push(['_trackEvent', 'Email Capture', 'Pageview', 'Digioh', 1, true]);
    DIGIOH_CUSTOM_JS.log('_gaq sent event - Email Capture');
}

DIGIOH_CUSTOM_JS_GLOBAL = {};
DIGIOH_CUSTOM_JS_GLOBAL.is_ga_universal = is_universal;
DIGIOH_CUSTOM_JS_GLOBAL.is_ga_classic = is_classic;

Step 4

In the “After Lightbox Display” section, copy and paste in the code below:
//Log display events as actions, with lightbox id detail for filtering. Classic and Universal have different methods.
if (DIGIOH_CUSTOM_JS_GLOBAL.is_ga_universal) {
    window.ga('send', 'event', 'Email Capture', 'Lightbox Display', lightbox_id, 1, {'nonInteraction': 1});
    DIGIOH_CUSTOM_JS.log('ga universal sent event - Lightbox Display: ' + lightbox_id);
}

if (DIGIOH_CUSTOM_JS_GLOBAL.is_ga_classic) {
    window._gaq.push(['_trackEvent', 'Email Capture', 'Lightbox Display', lightbox_id, 1, true]);
    DIGIOH_CUSTOM_JS.log('_gaq classic sent event - Lightbox Display: ' + lightbox_id);
}
	

Step 5

In the “After Lightbox Submit” section, copy and paste in the code below:
//SUBMIT EVENT

//Log submit events as actions, with lightbox id detail for filtering. Classic and Universal have different methods.
if (DIGIOH_CUSTOM_JS_GLOBAL.is_ga_universal) {
    window.ga('send', 'event', 'Email Capture', 'Lightbox Submit', lightbox_id, 1, {'nonInteraction': 1});
    DIGIOH_CUSTOM_JS.log('ga universal sent event - Lightbox Submit: ' + lightbox_id);
}

if (DIGIOH_CUSTOM_JS_GLOBAL.is_ga_classic) {
    window._gaq.push(['_trackEvent', 'Email Capture', 'Lightbox Submit', lightbox_id, 1, true]);
    DIGIOH_CUSTOM_JS.log('_gaq classic sent event - Lightbox Submit: ' + lightbox_id);
}
	

Step 6

Scroll to the bottom and make sure the “Settings” are set to “Production and Preview” in the drop down.

Step 7

Click on “Save Changes”

Step 8

 Open a new tab and Login to you Google Analytics account

Step 9

Click on “Admin” at the top
Creating a Goal for Displays

Step 10

Click on “Goals” under the “View” column 

Step 11

Click on the “+New Goal” button

Step 12

For “Goal setup” select “Custom” (Note that this you may have to scroll down a bit to see this)
Click Continue

Step 13

For Goal Description we ware going to put the following:
Name: “Lightbox Display”
Type: Event
Click Continue

Step 14

For Goal details we are going to put the following:
  • Category: Email Capture
  • Action: Lightbox Display

Special Note: The Category and Action fields are case sensitive so please play special attention to it.  

Step 15

Click Save 
Creating a Goal for Submits 

Step 16

Click on the “+New Goal” button

Step 17

For “Goal setup” select “Custom”

Step 18

For Goal Description we ware going to put the following:
Name: “Lightbox Submit”
Type: Event

Step 19

For Goal details we are going to put the following:
  • Category: Equals to: Email Capture
  • Action: Equals to: Lightbox Submit
  • Leave Label and Value empty

Special Note: The Category and Action fields are case sensitive so please play special attention to it.  

Step 20

Click Save
That's all there is to it! Your lightbox-related goals are now up and running in Google Analytics! Wait up to 1 hour before you will start seeing data in GA

Need any help? We are standing by! Send us an email and we can setup a call to walk you through it. We are also more than happy to install it for you :)