Set goal location through measurement protocol event - google-analytics

I'm using the measurement protocol to send an event to Google Analytics. The event shows up fine, but this event also completes a goal for us and the location keeps coming up as (entrance). I've looked around and read some suggestions saying that the cause might be a late (or non-existent) pageview in GA. This makes a bit of sense, since the event is fired from the backend. I'm using cURL to send the request to analytics and the request looks something like the code below. The goal completion location should be the WordPress page the user was previously on, which I've included by sending _wp_original_http_referer with the request.
$data = array(
'v' => '1',
'tid' => 'UA-XXXXXXXX',
't' => 'event',
'ec' => 'Category',
'ea' => 'Action',
'el' => 'Label',
'ev' => '0',
'dl' => $_REQUEST['_wp_original_http_referer']
);
Should I try a property other than dl? I've tried dp as well but had no luck. The documentation doesn't say much about specifying goal locations either.

Related

Using a single Cloudflare account in Wordpress with WP Super Cache with visible API key

We are starting to use Cloudflare on a few Wordpress client accounts and notice in the CDN settings that my email address and API key are visible to the client.
Is this a potential security issues where others can see my Cloudlflare email address and API key? Should I be using 1 Cloudflare account per client account?
Here is a screenshot (i have blurred the API key and deleted the email input box in the console) but both these values are visible to the customer.
What is the worse thing they could do with these 2 pieces of data?
you have to use tokens instead of global api key. you strict token to certain zone only
This only will NOT solve the problem, you have to manually modify wp fastest cache plugin to modify the request to match API tokens usage.
the requests can be found in inc\cdn.php
The modified file:
https://gist.github.com/ahmed-abdelazim/7c8170f7fc4e821c6b015d770fcbf14a
so
$header = array("method" => "DELETE",
'headers' => array(
"X-Auth-Email" => $email,
"X-Auth-Key" => $key,
"Content-Type" => "application/json"
),
"body" => '{"purge_everything":true}'
);
is converted to
$header = array("method" => "DELETE",
'headers' => array(
//"X-Auth-Email" => $email,
"Authorization" => "Bearer ".$key,
"Content-Type" => "application/json"
),
"body" => '{"purge_everything":true}'
);
and this occured five times in the plugin in the cdn.php file
simply creating API Token worked for me. There are some pre made template. There was for wordpress one as well. Just selected and created and added it to wp fastest cache and that worked.

Multiple async action execution order in single epic

I'm trying to setup loginEpic which occurs when user logs in. This is how the logic flow should work:
Epic should start with LOGIN_REQUEST action. Once login promise is finished successfully, user info should be fetched with SYNC_USER_REQUEST action (which is basically whole other epic since this is also called when initially entering site to get user info or redirect to login). Once that finishes successfully (promise and SUCCESS/FAIL calls are handled within syncUserEpic), SYNC_USER_SUCCESS should be caught in loginEpic and LOGIN_SUCCESS should be called along with push action which redirects user to starting page.
This is what I have so far:
const loginEpic: Types.RootEpic = (action$) =>
action$.ofType("LOGIN_REQUEST").pipe(
switchMap(({ payload }) =>
from(membershipService.login(payload.username, payload.password)).pipe(
switchMap((response) => [
syncUser.request(),
action$.ofType("SYNC_USER_SUCCESS").pipe( // I think this is the problem
filter(isActionOf(syncUser.success)),
map(r => login.success(response))
)
]),
takeUntil(action$.ofType(["LOGOUT_REQUEST", "LOGIN_CANCEL"])),
catchError(error => of(login.failure(error))),
endWith(push("/"))
)
)
)
but I'm getting
Actions must be plain objects. Use custom middleware for async
actions.
I'm also cancelling LOGIN_REQUEST/SYNC_USER_REQUEST with LOGOUT_REQUEST or LOGIN_CANCEL actions and also handling login error (I'm not sure if I should also handle sync user error here)
I've managed to implement it this way:
const loginEpic: Types.RootEpic = (action$) =>
action$.pipe(
filter(isActionOf(login.request)),
switchMap(({ payload }) =>
race(
from(membershipService.login(payload.username, payload.password)).pipe(
mergeMap((token) =>
from(membershipService.getUser()).pipe(
mergeMap((user) => [syncUser.success(user), login.success(token)]),
catchError(error => {
// user fetch failed, tell login that user is responsible
return of(login.failure(new BaseError("6010", "User sync failed.")));
})
)
),
catchError(error => of(login.failure(error))),
),
action$.pipe(
filter(isActionOf(logout.request)),
map(() => login.cancel()),
take(1)
)
)
)
)
Based on how it works, race is actually racing whole first block (so not just outer membershipService.login, with logout.request action. I was not aware of this, and I thought I would need another race condition for membershipService.getUser because what I need is that logout.request terminate whole process (even if login was successful and process in middle of fetching user). As far as I could test this, it's working as expected.
If anyone has any thoughts, improvements, fixes, or anti-pattern observations, please let me know.

jms payment corebundle integtation issue URL return

I'm integration the jms payment bundle in symfony 2.6.
I had followed all document in : http://jmspaymentcorebundle.readthedocs.io/en/stable/guides/accepting_payments.html
I'm getting this error :
You must configure a return url.
I had configured the return URL into ON in my account , and it seems not working, getting the same error.
My confirmation url is a page in which there is some text like :
Thank you for your payment. Your transaction has been completed,
and a receipt for your purchase has been emailed to you.
You may log into your account at www.paypal.com to view details of this transaction.
The error persists.
What should i do ?
Solved , they mean in the controller. I added :
'predefined_data' => array(
'paypal_express_checkout' => array(
'return_url' => $this->generateUrl('payment_complete', array(
'orderNumber' => $order->getOrderNumber(),
), true),
For more documentation http://jmspaymentpaypalbundle.readthedocs.io/en/latest/usage.html

Tracking offline purchases with Enhanced Ecommerce and Measurement Protocol

We've deployed Google Analytics Enhanced Ecommerce to better track our sales. Everything's working great except that some of our transactions are paid offline. We were already using the "standard" ecommerce analytics and this had been solved by reporting these transactions with the Measurement Protocol.
Right now we're unable to use MP in conjunction with Enhanced Ecommerce. Our reports seem to be accepted by the collection engine but they're not being linked to the Shopping Behaviour / Checkout Behaviour Reports (which is crucial for us).
Since the Enhanced Ecommerce is working for online payments, we're narrowing this down to our Measurement Protocol usage.
Here's an example of one such call:
'v' => 1,
'tid' => 'UA-XXXXXXXX-3',
'cid' => 'YYYYYYYYYY',
't' => 'pageview',
'ti' => 219950,
'ta' => 'our property name',
'tr' => 14.99,
'pa' => 'purchase',
'ni' => '0',
'pr1id' => '53731',
'pr1nm' => 'Product description',
'pr1pr' => '14.99',
'pr1qt' => '1',
'pr1ps' => 1,
We've tried sending the Hit Type ('t' parameter) as Event, instead of Pageview, with no success.
We're recording the Client ID ('cid' parameter) on the checkout. We've tried sending it with and without the timestamp (the numeric part that procedes the . separator).
We've trying sending this as a Non-Interactive hit ('ni' parameter).

wp_cron scheduled but not firing

I am trying to run a background script fired on a user action using wp_schedule_single_event, and although I have confirmed that the event is being scheduled and that wp_cron recognizes that the scheduled time has passed, it will not fire the event handler. To further complicate things, the code runs fine on my local WP install, but does nothing on my server.
To schedule the event, I am using:
if ( ! wp_next_scheduled( 'my_action_name' ) ) {
wp_schedule_single_event( time(), 'my_action_name' );
}
My handler action is defined as:
add_action('my_action_name', 'my_action_handler');
function my_action_handler () {
// do stuff
}
I have testing the wp core files and found that the following block (from wp-includes/cron.php:322) is where the script terminates:
var_dump('test1');
$cron_request = apply_filters( 'cron_request', array(
'url' => add_query_arg( 'doing_wp_cron', $doing_wp_cron, site_url( 'wp-cron.php' ) ),
'key' => $doing_wp_cron,
'args' => array(
'timeout' => 0.01,
'blocking' => false,
/** This filter is documented in wp-includes/class-wp-http-streams.php */
'sslverify' => apply_filters( 'https_local_ssl_verify', false )
)
), $doing_wp_cron );
var_dump('test2'); //exit here to test
wp_remote_post( $cron_request['url'], $cron_request['args'] );
On my local machine, the filter is applied, 'test2' is printed, and the script can continue to call wp_remote_post. On the server, however, the script terminates during the execution of apply_filter('cron_request'), printing 'test1' but not 'test2' and failing to reach wp_remost_post.
I have been unable to find the source for this filter to further debug. Wordpress.org says that the filter is defined within wp-includes/cron.php and that the one instance I have already cited is the only place it is ever applied, however, using Sublime multi-file search reveals that the string 'cron_request' appears only in the filter application I have cited.
I have read many post on wp_cron failing and have found no help other than non-descript 'Server configuration blocking wp_cron' answers. Any additional information on what type of server config or what else could be occuring here?
This action will trigger when someone visits your WordPress site, if the scheduled time has passed.
Maybe you can use
wp_schedule_event()
Instead of
wp_schedule_single_event()

Resources