How to track a Registration Form fields.
I have a "registration form" in my website. As usual we have common field like name, email id, address etc. Along with these we have two fileds which will have drop down menu to differentiate the users.
One Field name is Industry Type, this will have drop down menu like Health Care, Retail, Restaurants etc
Another one is User Type, this will have drop down menu like Merchant, Retails etc...
And all these users will have the same page after login.
Now i need to pass the Industry Type and User Type values to Analytics which the user selected while regestering.
Custom dimensions
In Google Analytics -> Tab Administration -> Tab Property -> Tab Custom Definitions -> Custom Dimensions
Create New Industry Type
Scope User
ID 1
Create New User Type
Scope User
ID 2
Tracking Code
ga("set","dimension1","Heavy Industry");
ga("set","dimension2","Super Customer");
OR
ga('send', 'event', 'Registration', 'New Member', {
'dimension1': "Heavy Industry",
'dimension2':'Super Customer'
});
OR TagManager
Create two dataLayer macros for industryType and userType
dataLayer.push({
'eventCategory':'Registration',
'eventAction':'New Member',
'industryType':'Heavy Industry',
'userType':'Super Customer',
'event':'fire'
});
Related
There's an action called 'woocommerce_checkout_create_order_line_item' where you can use the method 'add_meta_data(meta_key, meta_value)' to add meta data to the order item.
Every example did use this syntax: add_meta_data(__('Some key name', 'woocommerce'), $value);
This is perfect as long as the admin and the customer have set the same language and the field is only informal.
But I have to process the field programmatically later. So the key must always be the same, no matter which language is used.
So I use a simple string, but it won't be translated in the admin order area, on the Thank-You page, in the shopping cart etc. anymore.
How can I override the automatic output of the order item meta data? I've tried to hook i.e. into 'woocommerce_before_order_itemmeta($item_id, $item, $product)' (Admin order page), but there I can only delete $item->delete_meta_data('my_key'), I cannot add temporary meta keys => $item->add_meta_data(__('Translated key'), $value);
I also tried:
$item->set_meta_data(array('id' => 0, 'key' => __('Translated key'), 'value' => 'test123'));
print_r($item->get_meta_data());
Thanks!
There is no need to do the translation in the meta key.
What you could do is use the hook woocommerce_order_item_display_meta_key. There you can catch your key and output a tranlation for display.
Also you can filter keys to not display all custom meta keys if you have some keys that should not show up in the order details, but are for internal use only. This can be done with woocommerce_hidden_order_itemmeta
Here is a good post on working with order item meta data: https://www.ibenic.com/manage-order-item-meta-woocommerce/
Im trying to track an event that has 3 dimensions (user id, widget id,post id). Every click event must have its own row with a unique post id, user id and widget id so i can track the number of clicks per post. Extra: All the dimensions are set to have a scope of 'user'.
ga('send', 'event', 'widget', 'click', 'uwp',
{
'dimension1': $user_id,
'dimension2': $widget_id,
'dimension3': $post_id
}
);
I later query using the reporting api.
$result = Analytics::query(
$start_date,
$end_date,
'ga:totalEvents',
array(
'dimensions' => 'ga:dimension3,ga:pagePath,ga:date,ga:eventAction',
'sort' => '-ga:date',
'filters' => 'ga:eventAction==click;ga:eventLabel==uwp;ga:dimension1=='.$user->id,
'max-results'=> '100'
));
The result is incorrect all the clicks are being bundled up into 1 dimension, being dimension3 the post id.
Ex) If i click on a post of id 30 (dimension3 is set to 30) and a post of id 10 it will report that post of id 30 has 2 clicks or some older id has 2 clicks.
Google Analytics Dashbaord Picks:
As you can see from the pick i have 1 row with post id of 2 and 7 clicks, yet i sent events with many different post ids. (dimension3 == post id).
The problem here is that you are setting all of these dimensions to have a scope of user. Because of this, each dimension can only have one value per user. This is fine for the user id dimension, but for a dimension like post id, this is likely incorrect. Presumably, a user can view many post ids. Setting post id to user scope will cause the post id value to be overwritten with the latest post each time a new post is seen (which is why only one value is appearing in your report). You'll instead want to set post id to have a scope of hit, which will allow a different value to be sent on each event hit.
You can change the scope via the interface.
Read more about custom dimension scope.
I have created a login form using plugin "theme my login" in wordpress. I would like to make a field in login form in which if some one registering as new user then according to provide details of registering user the consequent field must be auto filled if any data match with any previous created user.
For example : There is two field in login form first " Introducer" and second "Introducer ID" if new user filled Introducer "ABCD" and if "ABCD" is already existed in user data as "username" then consequent fieled i.e. "Introducer ID" will automatically filled by existed User ID form user data base. If That "Introducer" text is not available in user data then error message displays that introducer not exists.
You could use theme-my-login template in order to add code :
Copy wp-content/plugins/theme-my-login/templates/login-form.php in your wordpress theme folder root (the plugin will check your theme path before the plugin path).
Add your code to get your current_user meta data ( check get_user_meta(); )
Check if user has already this value with WP_user_Query :
$user_query = new WP_User_Query( array( 'meta_key' => 'country',
'meta_value' => 'France' ) );
Hope it will help you !
I want to use google analytice ecommerce for some requirements.
So, I used the following code snippet from google.
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_trackPageview']);
_gaq.push(['_addTrans',
'1234', // order ID - required
'Womens Apparel', // affiliation or store name
'28.28', // total - required
'1.29', // tax
'15.00', // shipping
'San Jose', // city
'California', // state or province
'USA' // country
]);
_gaq.push(['_addItem',
'1234', // order ID - necessary to associate item with transaction
'DD44', // SKU/code - required
'T-Shirt', // product name
'Olive Medium', // category or variation
'11.99', // unit price - required
'1' // quantity - required
]);
_gaq.push(['_trackTrans']);
So with this code sample my transactions are getting tracked.
But in my google analytics profile, I'm not seeing the city, state, country. Though other details like order_id, shipping, etc SKU are getting tracked.
Please let me know if you have any idea on this.
Thanks,
Uttam
All other variables within the addTrans method are optional.
The affiliate field is not required, and was removed from the Google
Analytics Ecommerce reports. You can still use the affiliate field for
custom reports and filtering.
Tax and shipping appear in the transactions report if you have access
to those variables.
The city, state, and country are currently not being used by Google
Analytics, but the information is still being collected. You can
however use these fields within the profile filters if you have a use
for them.
Source: http://www.roirevolution.com/blog/2009/05/stressing_about_your_ga_ecommerce.php
I may be missing something blindingly obvious here (I hope so).....I am creating a module in Drupal 6 that consists of some triggers and actions. in it's simplest form it consists of:
An action which checks for some criteria (event that needs to be triggered once a month per user)
A trigger which is fired for each user that the criteria is true for
I would like as much as possible to be managed through the triggers / actions interface in Drupal as the site admin is not a developer. The plan is to use the cron trigger to fire the action in 1. which will then fire a trigger for each user. The site admin will then be able to create a Send Email action through the actions interface and hook it up to the trigger from 2.
The part I can't get my head around is how the recipient of the email will be specified - the user trigger will be fired from an action run by cron (i.e. not in any user context) - how can I pass in a variable that can be used here?
Thanks,
Triggers fire actions not the other way around.
The user that you pass to actions_do dosn't have to be the logged in user. You can query for the users that you want to email and loop thrhough them doing user_load and then an actions_do
something like
foreach ($user_ids as $uid) {
$context_user = user_load(array('uid' => $uid));
$context = array(
'hook' => 'myhook',
'op' => $op,
'user' => $context_user,
);
actions_do(array_keys($aids), $context_user, $context);
}