Skip to content

Instantly share code, notes, and snippets.

View brunomertins's full-sized avatar

Bruno Mertins brunomertins

View GitHub Profile
SELECT
-- Date (dimension)
event_date AS date,
-- Year (dimension)
FORMAT_DATE('%Y', PARSE_DATE("%Y%m%d",
event_date)) AS year,
-- ISO Year (dimension)
FORMAT_DATE('%G', PARSE_DATE("%Y%m%d",
event_date)) AS iso_year,
-- Month of Year (dimension)
WITH
-- Subquery to set the start and end date once for the whole query
period AS (
SELECT
'20200220' AS start_date,
FORMAT_DATE('%Y%m%d',DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY)) AS end_date),
-- Subquery to prepare and calculate traffic source data based on user and session id
traffic AS (
SELECT
user_pseudo_id,
WITH
-- Subquery to define static and/or dynamic start and end date for the whole query
period AS (
SELECT
'20200220' AS start_date,
FORMAT_DATE('%Y%m%d',DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY)) AS end_date)
SELECT
-- Event count per user (metric | the number of times an individual event (change event_name 'page_view' to event that needs to be counted) was triggered divided by amount of users)
COUNT(DISTINCT
CASE
WITH
-- Subquery to define static and/or dynamic start and end date for the whole query
period AS (
SELECT
'20200220' AS start_date,
FORMAT_DATE('%Y%m%d',DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY)) AS end_date),
-- Subquery to prepare and calculate page view data
pages AS (
SELECT
user_pseudo_id,
@brunomertins
brunomertins / Resultados de Busqueda
Created March 28, 2015 14:59
Resultados de Busqueda
//* Customize search text
add_filter( 'genesis_search_title_text', 'search_title_text' );
function search_title_text() {
return 'Resultados de búsqueda: ';
}
@brunomertins
brunomertins / Colums Example
Created November 21, 2014 15:47
Colums Example
<div class="one-half first"><strong>Gmail for business</strong>
Custom made email addresses: (your_name@your_company.com).</div>
<div class="one-half"><strong>Google Docs</strong>
Share online documents, spreadsheets and presentations.</div>
<div class="one-half first"><strong>Google Calendar</strong>
Your meetings and company events in one place.</div>
<div class="one-half"><strong>Google Sites</strong>
Create your own intranet and wikis without programing.</div>
<script src="http://www.google.com/jsapi"></script>
<script>
google.load("jquery", "1");
google.load("jqueryui", "1");
</script>
<script>
$(document).ready(function()
{
$('body').hide().fadeIn(500);
});
@brunomertins
brunomertins / GA Comments Event Tracking
Last active August 29, 2015 14:03
Google Analytics Comments Event Tracking
<input name="submit" type="submit" onClick="_gaq.push(['_trackEvent', 'Forms', 'Submit', 'BlogComments']);" id="<?php echo esc_attr( $args['id_submit'] ); ?>" value="<?php echo esc_attr( $args['label_submit'] ); ?>" />
<?php
//* Do NOT include the opening php tag
//* Enqueue sticky menu script
add_action( 'wp_enqueue_scripts', 'custom_enqueue_script' );
function custom_enqueue_script() {
wp_enqueue_script( 'sticky-menu', get_stylesheet_directory_uri() . '/js/sticky-menu.js', array( 'jquery' ), '', true );
}
//* Reposition the secondary navigation menu
@brunomertins
brunomertins / Spanish Acent Entity Codes
Created April 18, 2013 13:47
Quick Reference Spanish Accent Entity Codes
á --> &aacute;
é --> &eacute;
í --> &iacute;
ó --> &oacute;
ú --> &uacute;
ñ --> &ntilde;