Skip to content

Instantly share code, notes, and snippets.

@deconf
deconf / gadwpendpointtest.php
Last active February 9, 2018 20:07
GADWP Endpoint Test
<?php
/**
* Author: Alin Marcu
* Copyright 2018 Alin Marcu
* Author URI: https://deconf.com
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
$curl = curl_init();
@deconf
deconf / functions.php
Last active March 15, 2018 19:28
Adds userId support for Universal Analytics in GADWP
/* Analytics Code */
function gadwp_addcode( $gadwp ) {
$commands = $gadwp->get(); // Get commands array
$fields = array();
$fields['option'] = 'userId';
$fields['value'] = get_current_user_id();
if ( $fields['value'] ){
$command = array( $gadwp->prepare( 'set', $fields ) );
array_splice( $commands, -1, 0, $command ); //insert the command before send
}
@deconf
deconf / functions.php
Last active January 19, 2018 16:17
Examples for GADWP v5 Tracking Code customization
<?php
/* Analytics Code */
function gadwp_addcode( $gadwp ) {
$commands = $gadwp->get(); // Get commands array
array_pop( $commands ); // Pop the last element
$fields = array();
$fields['hitType'] = 'pageview';
$commands[] = $gadwp->prepare( 'send', $fields ); // Add a new line to the commands array
@deconf
deconf / functions.php
Last active December 14, 2016 15:00
URI correction for backend Posts/Pages List
add_filter( 'gadwp_backenditem_uri', 'gadwp_uri_correction', 10, 2 );
function gadwp_uri_correction( $uri, $filter_id ){
$newuri = str_replace( '/test', '', $uri ); //it could be anything, we are removing /test as an example
return $newuri;
}
@deconf
deconf / functions.php
Last active March 18, 2017 12:35
Adjust GADWP bouncerate using an event
<?php
function gadwp_bouncerate_adjustment() {
?>
<script type="text/javascript">
setTimeout( "ga('send','event','Read Engagement','time on page more than 10 seconds')", 10000 );
</script>
<?php
}
add_action( 'wp_footer', 'gadwp_bouncerate_adjustment', 100 );
?>