I’m having with google analytics. My UTM tags are not being tracked. And FYI, the transaction and product name is showing up, it’s JUST the utm parameters that are not.
This is done within functions.php of a WordPress site.
upon submission of a gravity form, we are grabbing all the info entered and placing them in the $ga_body array. Then submitting it to https://www.google-analytics.com/collect with the wp_remote_post function.
Here’s my code:
FYI I’m using stripe (https://stripe.com/) to process donations, so $stripe_id is just that transaction id.
$ga_body = array(); //clear out ga_body
$ga_body['v'] = 1; // Version.
$ga_body['tid']= 'UA-XXXXXXXX-2'; // Tracking ID / Property ID.
$ga_body['cid']= $stripe_id; // Anonymous Client ID.
$ga_body['cn'] = 'this is the utm source';
$ga_body['cs'] = 'this is the utm campaign';
$ga_body['cm'] = 'this is the utm source';
$ga_body['dl'] = 'www.example.com';
$ga_body['t'] = 'item'; // Transaction hit type.
$ga_body['ti'] = $stripe_id; // transaction ID. Required.
$ga_body['in'] = 'donation'; // item name.
$ga_body['iq'] = 1; // Transaction shipping.
$post_url = 'https://www.google-analytics.com/collect';
$response = wp_remote_post( $post_url, array(
'method' => 'POST',
'timeout' => 45,
'redirection' => 5,
'httpversion' => '1.0',
'blocking' => false,
'headers' => array(),
'body' => $ga_body
)
);
And I have tested this code by printing out $ga_body and verifying all the data in it. All the data passed to the array is correct. Am I doing something wrong with the analytics??
Thank you