Connect Google Analytics

Tip

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">
    <ul>
        <li class="active">PHP</li>
        <li>cURL</li>
        <li>Ruby</li>
        <li>Python</li>
    </ul>

    <!-- PHP SDK Sample -->
    <pre class="prettyprint php">&lt;?php
// WePay PHP SDK - http://git.io/mY7iQQ
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(
    'UA-23421-01',
    'UA-23421-02'
);

// 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 https://stage.wepayapi.com/v2/app/modify \
-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"
			</pre>

    <!-- Ruby SDK Sample -->
    <pre class="prettyprint ruby"># WePay Ruby SDK - http://git.io/a_c2uQ 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 = WePay::Client.new(client_id, client_secret, _use_stage = true)

modify your application

response = wepay.call(‘/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 - http://git.io/v7Y1jA 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 = wepay.call(‘/app/modify’, { ‘client_id’: client_id, ‘client_secret’: client_secret, ‘gaq_domains’: gaq_domains })

display the response

print response</pre>

</div>


<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>
    </div>
</div>

<h4>Response:</h4>
<pre class="prettyprint">{
"client_id":32005,
"status":"approved",
"gaq_domains":
[
    "UA-23421-01",
    "UA-23513-02"
] }</pre>

</section>

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 www.wepay.com to complete their payment (either because they chose to pay with a saved payment method or we could not set cookies within the iframe)
What's
Next?