WePay

Connect Google Analytics

Before reading this tutorial...

You should be familiar with the following concepts:

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.

Provide your Google Analytics Account ID

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

You can enter your Google Analytics Account ID via the /app/modify call using the gaq_domains parameter. To make the /app/modify call, you'll need your client_secret, which you can find on your dashboard.

API Call:

  • PHP
  • cURL
  • Ruby
  • Python
<?php
    // WePay PHP SDK - http://git.io/mY7iQQ
    require 'wepay.php';

    // application settings
    $client_id = 123456789;
    $client_secret = "1a3b5c7d9";
    $access_token = "1a3b5c7d9";

    // google analytics ids
    $gaq_domains = 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'     => $client_id,
        'client_secret' => $client_secret,
        'gaq_domains'   => $gaq_domains
    ));

    // display the response
    print_r($response);
?>
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"
				
# WePay Ruby SDK - http://git.io/a_c2uQ
require 'WePay_API_v2_Ruby_SDK.rb'

# 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.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
# 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

Monitor user payment funnels

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 /account/create call (or /account/modify call) using the gaq_domains parameter.

Response:

{
    "client_id":32005,
    "status":"approved",
    "gaq_domains":
    [
        "UA-23421-01",
        "UA-23513-02"
    ]
}

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?