Connect Google Analytics


Before reading this tutorial…
You should be familiar with the following concepts: Making API calls

WePay can send your Google Analytics account all the pageviews and user events associated with your App. This will allow you to monitor your payment funnel.</p>

Provide your Google Analytics Account ID

In order for us to propagate analytics data, we need your Google Analytics Account ID.

API Call:

<!-- Code Sample -->
<div class="code-sample">
        <li class="active">PHP</li>

    <!-- PHP SDK Sample -->
    <pre class="prettyprint php">&lt;?php
// WePay PHP SDK -
require 'wepay.php';

// application settings
<span class="variable">$client_id</span> = 123456789;
<span class="variable">$client_secret</span> = "1a3b5c7d9";
<span class="variable">$access_token</span> = "1a3b5c7d9";

// google analytics ids
<span class="variable">$gaq_domains</span> = array(

// change to useProduction for live environments
Wepay::useStaging($client_id, $client_secret);

$wepay = new WePay($access_token);

// modify your application
$response = $wepay->request('app/modify', array(
    'client_id'     =&gt; $client_id,
    'client_secret' =&gt; $client_secret,
    'gaq_domains'   =&gt; $gaq_domains

// display the response
print_r($response); ?&gt;</pre>

			<pre class="prettyprint curl"> curl \
-H "Authorization: Bearer STAGE_8a19aff55b85a436dad5cd1386db1999437facb5914b494f4da5f206a56a5d20" \
-d "client_id=123456789" \
-d "client_secret=1a3b5c7d9" \
-d "gaq_domains[0]=UA-23421-01" \
-d "gaq_domains[1]=UA-23421-02"

    <!-- Ruby SDK Sample -->
    <pre class="prettyprint ruby"># WePay Ruby SDK - require 'wepay'

application settings

client_id = 123456789 client_secret = ‘1a3b5c7d9’ access_token = ‘1a3b5c7d9’

google analytics ids

gaq_domains = { ‘UA-23421-01’, ‘UA-23421-02’ }

set _use_stage to false for live environments

wepay =, client_secret, _use_stage = true)

modify your application

response =‘/app/modify’, access_token, { :client_id => client_id, :client_secret => client_secret, :gaq_domains => gaq_domains })

display the response

p response</pre>

    <!-- Python SDK Sample -->
    <pre class="prettyprint python"># WePay Python SDK - from wepay import WePay

application settings

client_id = 123456789 client_secret = ‘1a3b5c7d9’ access_token = ‘1a3b5c7d9’ production = False

google analytics ids

gaq_domains = [ ‘UA-23421-01’, ‘UA-23421-02’ ]

set production to True for live environments

wepay = WePay(production, access_token)

modify your application

response =‘/app/modify’, { ‘client_id’: client_id, ‘client_secret’: client_secret, ‘gaq_domains’: gaq_domains })

display the response

print response</pre>


<div class="notice tip">
    <div class="inner clearfix">
        <h4>Monitor user payment funnels</h4>
        <p>If you're a platform or marketplace and you're creating accounts for your users, you can also send us their Google Analytics Account IDs, so they can monitor their own individual payment funnels. Just send us the Google Analytics Account IDs during the <a href="/developer/reference/account#create" class="inline-call">/account/create</a> call (or <a href="/developer/reference/account#modify" class="inline-call">/account/modify</a> call) using the <span class="inline-call">gaq_domains</span> parameter.</p>

<pre class="prettyprint">{
] }</pre>


Events you'll receive

Your Google Analytics account will be sent all pageviews associated with your app, plus the following events from the "WePay Payment" events category:

Event Description
api checkout - iframe/onsite - start Fired when a user enters the payment flow - differentiates between iframe and onsite
api preapproval - iframe/onsite - start Fired when preapproval state changes to 'start' - differentiates between iframe and onsite
{object type} - iframe - start Fired when object state changes to 'start' - checkout, preapproval, withdrawal or account
payment flow - iframe/onsite - error Fired when a user sees an error - differentiates between iframe and onsite. Includes error message.
payment flow - onsite - switched from iframe Fired when a user goes from the iframe to to complete their payment (either because they chose to pay with a saved payment method or we could not set cookies within the iframe)