Skip to content

Commit a1e938a

Browse files
committed
More tracking stuff
1 parent 98d9048 commit a1e938a

File tree

13 files changed

+84
-2875
lines changed

13 files changed

+84
-2875
lines changed

Nebula-Child/style.css

Lines changed: 3 additions & 858 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/css/admin.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/css/dev.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11

2-
/* Processed on Saturday, April 15, 2017 at 11:38am */
2+
/* Processed on Monday, April 17, 2017 at 9:24pm */

assets/css/login.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/css/pre.css

Lines changed: 2 additions & 183 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/css/tinymce.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/css/wireframing.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/main.js

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ jQuery(function(){
5858
initEventTracking();
5959
}
6060

61-
//@todo "Nebula" 0: double check we can send data to nv() using query strings like ?nv_first_name=Chris and even encode it like
62-
6361
//Remove Sass render trigger query
6462
if ( get('sass') && !get('persistent') && window.history.replaceState ){
6563
window.history.replaceState({}, document.title, removeQueryParameter('sass', window.location.href));
@@ -1596,7 +1594,13 @@ function cf7Functions(){
15961594
return false;
15971595
}
15981596

1599-
//@todo "Nebula" 0: Include an event when a CF7 form is scrolled into view.
1597+
//Track CF7 forms when they scroll into view (Autotrack). Currently not possible to change category/action/label for just these impressions.
1598+
jQuery('form.wpcf7-form').each(function(){
1599+
ga('impressionTracker:observeElements', [{
1600+
'id': jQuery(this).closest('.wpcf7').attr('id'),
1601+
'threshold': 0.25
1602+
}]);
1603+
});
16001604

16011605
formStarted = [];
16021606
jQuery('.wpcf7-form input, .wpcf7-form textarea').on('focus', function(){
@@ -1628,7 +1632,10 @@ function cf7Functions(){
16281632
});
16291633

16301634
//CF7 Invalid (CF7 AJAX response after invalid form)
1631-
nebula.dom.document.on('wpcf7:invalid', function(e){
1635+
nebula.dom.document.on('wpcf7invalid', function(e){
1636+
console.log('old invalid');
1637+
console.debug(e.target.id);
1638+
console.debug(e);
16321639
var formTime = nebulaTimer(e.target.id, 'lap', 'wpcf7-submit-spam');
16331640
ga('set', gaCustomDimensions['contactMethod'], 'CF7 Form (Invalid)');
16341641
ga('set', gaCustomDimensions['formTiming'], millisecondsToString(formTime) + 'ms (' + nebulaTimings[e.target.id].laps + ' inputs)');
@@ -1638,8 +1645,15 @@ function cf7Functions(){
16381645
nv('append', {'form_submission_error': 'Validation (' + e.target.id + ')'});
16391646
});
16401647

1648+
//General HTML5 validation errors
1649+
jQuery('.wpcf7-form input').on('invalid', function(){ //Would it be more useful to capture all inputs (rather than just CF7)? How would we categorize this in GA?
1650+
debounce(function(){
1651+
ga('send', 'event', 'CF7 Form', 'Submit (Invalid)', 'General HTML5 validation error');
1652+
}, 50, 'invalid form');
1653+
});
1654+
16411655
//CF7 Spam (CF7 AJAX response after spam detection)
1642-
nebula.dom.document.on('wpcf7:spam', function(e){
1656+
nebula.dom.document.on('wpcf7spam', function(e){
16431657
var formTime = nebulaTimer(e.target.id, 'end');
16441658
ga('set', gaCustomDimensions['contactMethod'], 'CF7 Form (Spam)');
16451659
ga('set', gaCustomDimensions['formTiming'], millisecondsToString(formTime) + 'ms (' + nebulaTimings[e.target.id].laps + ' inputs)');
@@ -1649,7 +1663,7 @@ function cf7Functions(){
16491663
});
16501664

16511665
//CF7 Mail Send Failure (CF7 AJAX response after mail failure)
1652-
nebula.dom.document.on('wpcf7:mailfailed', function(e){
1666+
nebula.dom.document.on('wpcf7mailfailed', function(e){
16531667
var formTime = nebulaTimer(e.target.id, 'end');
16541668
ga('set', gaCustomDimensions['contactMethod'], 'CF7 Form (Failed)');
16551669
ga('set', gaCustomDimensions['formTiming'], millisecondsToString(formTime) + 'ms (' + nebulaTimings[e.target.id].laps + ' inputs)');
@@ -1659,7 +1673,7 @@ function cf7Functions(){
16591673
});
16601674

16611675
//CF7 Mail Sent Success (CF7 AJAX response after submit success)
1662-
nebula.dom.document.on('wpcf7:mailsent', function(e){
1676+
nebula.dom.document.on('wpcf7mailsent', function(e){
16631677
var formTime = nebulaTimer(e.target.id, 'end');
16641678
if ( !jQuery('#' + e.target.id).hasClass('.ignore-form') && !jQuery('#' + e.target.id).find('.ignore-form').length ){
16651679
ga('set', gaCustomMetrics['formSubmissions'], 1);
@@ -1681,7 +1695,7 @@ function cf7Functions(){
16811695
});
16821696

16831697
//CF7 Submit (CF7 AJAX response after any submit attempt). This triggers after the other submit triggers.
1684-
nebula.dom.document.on('wpcf7:submit', function(e){
1698+
nebula.dom.document.on('wpcf7submit', function(e){
16851699
var formTime = nebulaTimer(e.target.id, 'lap', 'wpcf7-submit-attempt');
16861700
nvForm(); //nvForm() here because it triggers after all others. No nv() here so it doesn't overwrite the other (more valuable) data.
16871701
ga('set', gaCustomDimensions['contactMethod'], 'CF7 Form (Attempt)');
@@ -3155,18 +3169,18 @@ function nebulaHTML5VideoTracking(){
31553169
oThis.on('ended', function(){
31563170
ga('set', gaCustomMetrics['videoCompletions'], 1);
31573171
ga('set', gaCustomMetrics['videoPlaytime'], Math.round(videoData[id].watched));
3158-
ga('set', gaCustomDimensions['videoWatcher'], 'Finished');
3172+
ga('set', gaCustomDimensions['videoWatcher'], 'Ended');
31593173
ga('set', gaCustomDimensions['timestamp'], localTimestamp());
31603174

3161-
finishedAction = 'Finished';
3175+
endedAction = 'Ended';
31623176
if ( !isInView(jQuery('#' + id)) ){
3163-
finishedAction = 'Finished (Not In View)';
3177+
endedAction = 'Ended (Not In View)';
31643178
}
3165-
ga('send', 'event', 'Videos', finishedAction, videoTitle, Math.round(videoData[id].watched), {'nonInteraction': true});
3179+
ga('send', 'event', 'Videos', endedAction, videoTitle, Math.round(videoData[id].watched), {'nonInteraction': true});
31663180

3167-
ga('send', 'timing', 'Videos', 'Finished', Math.round(videoData[id].watched*1000), videoTitle); //Roughly amount of time watched (Can not be over 100% for Vimeo)
3168-
nv('append', {'video_finished': videoTitle});
3169-
nebula.dom.document.trigger('nebula_finished_video', id);
3181+
ga('send', 'timing', 'Videos', 'Ended', Math.round(videoData[id].watched*1000), videoTitle); //Roughly amount of time watched (Can not be over 100% for Vimeo)
3182+
nv('append', {'video_ended': videoTitle});
3183+
nebula.dom.document.trigger('nebula_ended_video', id);
31703184
});
31713185
});
31723186
}
@@ -3279,18 +3293,18 @@ function onPlayerStateChange(e){
32793293
clearTimeout(youtubePlayProgress);
32803294
ga('set', gaCustomMetrics['videoCompletions'], 1);
32813295
ga('set', gaCustomMetrics['videoPlaytime'], Math.round(videoData[id].watched/1000));
3282-
ga('set', gaCustomDimensions['videoWatcher'], 'Finished');
3296+
ga('set', gaCustomDimensions['videoWatcher'], 'Ended');
32833297
ga('set', gaCustomDimensions['timestamp'], localTimestamp());
32843298

3285-
finishedAction = 'Finished';
3299+
endedAction = 'Ended';
32863300
if ( !isInView(jQuery(videoData[id].iframe)) ){
3287-
finishedAction = 'Finished (Not In View)';
3301+
endedAction = 'Ended (Not In View)';
32883302
}
3289-
ga('send', 'event', 'Videos', finishedAction, videoInfo.title, Math.round(videoData[id].watched/1000), {'nonInteraction': true});
3303+
ga('send', 'event', 'Videos', endedAction, videoInfo.title, Math.round(videoData[id].watched/1000), {'nonInteraction': true});
32903304

3291-
ga('send', 'timing', 'Videos', 'Finished', videoData[id].watched*1000, videoInfo.title); //Amount of time watched (can exceed video duration).
3292-
nv('append', {'video_finished': videoInfo.title});
3293-
nebula.dom.document.trigger('nebula_finished_video', videoInfo);
3305+
ga('send', 'timing', 'Videos', 'Ended', videoData[id].watched*1000, videoInfo.title); //Amount of time watched (can exceed video duration).
3306+
nv('append', {'video_ended': videoInfo.title});
3307+
nebula.dom.document.trigger('nebula_ended_video', videoInfo);
32943308
} else if ( e.data === YT.PlayerState.PAUSED && pauseFlag ){
32953309
clearTimeout(youtubePlayProgress);
32963310
ga('set', gaCustomMetrics['videoPlaytime'], Math.round(videoData[id].watched));
@@ -3434,18 +3448,18 @@ function nebulaVimeoTracking(){
34343448
var videoTitle = id.replace(/-/g, ' ');
34353449
ga('set', gaCustomMetrics['videoCompletions'], 1);
34363450
ga('set', gaCustomMetrics['videoPlaytime'], Math.round(videoData[id].watched));
3437-
ga('set', gaCustomDimensions['videoWatcher'], 'Finished');
3451+
ga('set', gaCustomDimensions['videoWatcher'], 'Ended');
34383452
ga('set', gaCustomDimensions['timestamp'], localTimestamp());
34393453

3440-
finishedAction = 'Finished';
3454+
endedAction = 'Ended';
34413455
if ( !isInView(jQuery(players.vimeo[id])) ){
3442-
finishedAction = 'Finished (Not In View)';
3456+
endedAction = 'Ended (Not In View)';
34433457
}
3444-
ga('send', 'event', 'Videos', finishedAction, videoTitle, Math.round(videoData[id].watched), {'nonInteraction': true});
3458+
ga('send', 'event', 'Videos', endedAction, videoTitle, Math.round(videoData[id].watched), {'nonInteraction': true});
34453459

3446-
ga('send', 'timing', 'Videos', 'Finished', Math.round(videoData[id].watched*1000), videoTitle); //Roughly amount of time watched (Can not be over 100% for Vimeo)
3447-
nv('append', {'video_finished': videoTitle});
3448-
nebula.dom.document.trigger('nebula_finished_video', id);
3460+
ga('send', 'timing', 'Videos', 'Ended', Math.round(videoData[id].watched*1000), videoTitle); //Roughly amount of time watched (Can not be over 100% for Vimeo)
3461+
nv('append', {'video_ended': videoTitle});
3462+
nebula.dom.document.trigger('nebula_ended_video', id);
34493463
}
34503464
}
34513465

assets/scss/style.scss

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Description: Nebula is a springboard WordPress theme framework for developers. Like other WordPress startup themes, it has custom functionality built-in (like shortcodes, styles, and JS/PHP functions), but unlike other themes Nebula is not meant for the end-user.
55
Author: Pinckney Hugo Group
66
Author URI: http://www.pinckneyhugo.com
7-
Version: 4.11.14
7+
Version: 4.11.16
88
License: GNU General Public License v2.0 or later
99
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1010
Tags: one-column, two-columns, three-columns, four-columns, left-sidebar, right-sidebar, threaded-comments, theme-options, sticky-post, post-formats, microformats, full-width-template, front-page-post-form, flexible-header, featured-images, featured-image-header, editor-style, custom-menu, custom-colors, accessibility-ready
@@ -437,8 +437,10 @@ iframe[name='google_conversion_frame'] {height: 0 !important; width: 0 !importan
437437
}
438438
}
439439

440-
.nebula-color-overlay {position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(to right, #5B22E8, #FF2362); animation: nebulahero 60s infinite linear; opacity: 0.7; z-index: 0; pointer-events: none;
441-
#footer-section &:after {content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.8); z-index: 1; pointer-events: none;}
440+
.nebula-color-overlay {position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(to right, #5B22E8, #FF2362); animation: nebulahero 60s infinite linear; opacity: 0.75; z-index: 0; pointer-events: none;
441+
#footer-section & {opacity: 0.85;
442+
&:after {content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.7); z-index: 1; pointer-events: none;}
443+
}
442444
}
443445
@keyframes nebulahero {
444446
0% {@include prefix((filter: hue-rotate(0deg)));}

inc/analytics.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,9 @@
371371
});
372372
}
373373

374+
//Autotrack Impressions (Scroll into view)
375+
ga('require', 'impressionTracker'); //Elements are detected in main.js (or child.js)
376+
374377
//Autotrack Max Scroll
375378
ga('require', 'maxScrollTracker', {
376379
maxScrollMetricIndex: parseInt(gaCustomMetrics['maxScroll'].replace('metric', '')),
@@ -388,8 +391,7 @@
388391

389392
<?php do_action('nebula_ga_before_send_pageview'); //Hook into for adding more custom definitions before the pageview hit is sent. Can override any above definitions too. ?>
390393

391-
//Send pageview with all custom dimensions and metrics
392-
ga('send', 'pageview');
394+
ga('send', 'pageview'); //Send pageview with all custom dimensions and metrics
393395

394396
<?php do_action('nebula_ga_after_send_pageview'); ?>
395397

@@ -438,8 +440,19 @@ function localTimestamp(){return false;}
438440
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
439441
document,'script','//connect.facebook.net/en_US/fbevents.js');
440442

441-
fbq('init', '<?php echo nebula()->option('facebook_custom_audience_pixel_id'); ?>');
443+
<?php if ( nebula()->option('visitors_db') ): ?>
444+
fbq('init', '<?php echo nebula()->option('facebook_custom_audience_pixel_id'); ?>', {
445+
em: '<?php echo nebula()->get_visitor_datapoint('email_address'); ?>',
446+
fn: '<?php echo nebula()->get_visitor_datapoint('first_name'); ?>',
447+
ln: '<?php echo nebula()->get_visitor_datapoint('last_name'); ?>',
448+
});
449+
<?php else: ?>
450+
fbq('init', '<?php echo nebula()->option('facebook_custom_audience_pixel_id'); ?>');
451+
<?php endif; ?>
452+
442453
fbq('track', 'PageView');
454+
455+
<?php do_action('nebula_fbq_after_track_pageview'); //Hook into for adding more Facebook custom audience tracking. ?>
443456
</script>
444457
<noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=<?php echo nebula()->option('facebook_custom_audience_pixel_id'); ?>&ev=PageView&noscript=1"/></noscript>
445458
<?php endif; ?>

0 commit comments

Comments
 (0)