You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ha...@apache.org on 2011/03/15 07:48:29 UTC
svn commit: r1081673 - in /ofbiz/trunk/specialpurpose/googlebase:
entitydef/entitymodel.xml servicedef/services.xml
src/org/ofbiz/googlebase/ProductsExportToGoogle.java
widget/GoogleBaseForms.xml
Author: hansbak
Date: Tue Mar 15 06:48:28 2011
New Revision: 1081673
URL: http://svn.apache.org/viewvc?rev=1081673&view=rev
Log:
add tagging to googlebase on the url to allow google ananlytics to report on the source
Modified:
ofbiz/trunk/specialpurpose/googlebase/entitydef/entitymodel.xml
ofbiz/trunk/specialpurpose/googlebase/servicedef/services.xml
ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java
ofbiz/trunk/specialpurpose/googlebase/widget/GoogleBaseForms.xml
Modified: ofbiz/trunk/specialpurpose/googlebase/entitydef/entitymodel.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/googlebase/entitydef/entitymodel.xml?rev=1081673&r1=1081672&r2=1081673&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/googlebase/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/specialpurpose/googlebase/entitydef/entitymodel.xml Tue Mar 15 06:48:28 2011
@@ -48,6 +48,11 @@ under the License.
<field name="accountPassword" type="name" encrypt="true"></field>
<field name="postItemsUrl" type="value"><description>All the items should be posted to this url</description></field>
<field name="webSiteId" type="id-ne"></field>
+ <field name="utmSource" type="id-ne"><description>Campaign Source (referrer: google, citysearch, newsletter4)</description></field>
+ <field name="utmMedium" type="id-ne"><description>Campaign Medium (marketing medium: cpc, banner, email)</description></field>
+ <field name="utmTerm" type="id-ne"><description>Campaign Term (identify the paid keywords)</description></field>
+ <field name="utmContent" type="id-ne"><description>Campaign Content (use to differentiate ads)</description></field>
+ <field name="utmCampaign" type="id-ne"><description>Campaign Name (product, promo code, or slogan)</description></field>
<prim-key field="productStoreId"/>
<relation type="one" fk-name="GBS_PROD_STORE" rel-entity-name="ProductStore">
<key-map field-name="productStoreId"/>
Modified: ofbiz/trunk/specialpurpose/googlebase/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/googlebase/servicedef/services.xml?rev=1081673&r1=1081672&r2=1081673&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/googlebase/servicedef/services.xml (original)
+++ ofbiz/trunk/specialpurpose/googlebase/servicedef/services.xml Tue Mar 15 06:48:28 2011
@@ -38,6 +38,11 @@ under the License.
<attribute type="String" mode="IN" name="countryCode" optional="false"/>
<attribute type="String" mode="IN" name="productStoreId" optional="true"/>
<attribute type="String" mode="IN" name="allowRecommended" optional="true"/>
+ <attribute type="String" mode="IN" name="utmSource" optional="true"/>
+ <attribute type="String" mode="IN" name="utmMedium" optional="true"/>
+ <attribute type="String" mode="IN" name="utmTerm" optional="true"/>
+ <attribute type="String" mode="IN" name="utmContent" optional="true"/>
+ <attribute type="String" mode="IN" name="utmCampaign" optional="true"/>
</service>
<service name="exportProductCategoryToGoogle" engine="java"
location="org.ofbiz.googlebase.ProductsExportToGoogle" invoke="exportProductCategoryToGoogle" auth="true">
Modified: ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java?rev=1081673&r1=1081672&r2=1081673&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java (original)
+++ ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java Tue Mar 15 06:48:28 2011
@@ -305,6 +305,8 @@ public class ProductsExportToGoogle {
List<String> newProductsInGoogle = FastList.newInstance();
List<String> productsRemovedFromGoogle = FastList.newInstance();
String localeString = null;
+ String productStoreId = (String) context.get("productStoreId");
+
try {
Delegator delegator = dctx.getDelegator();
LocalDispatcher dispatcher = dctx.getDispatcher();
@@ -315,7 +317,56 @@ public class ProductsExportToGoogle {
String trackingCodeId = (String)context.get("trackingCodeId");
String countryCode = (String)context.get("countryCode");
String webSiteMountPoint = (String)context.get("webSiteMountPoint");
-
+ //Tagging Links
+ String utmSource = null;
+ String utmMedium = null;
+ String utmTerm = null;
+ String utmContent = null;
+ String utmCampaign = null;
+
+ if (UtilValidate.isNotEmpty(productStoreId)) {
+ GenericValue googleBaseConfig = null;
+ try {
+ googleBaseConfig = delegator.findOne("GoogleBaseConfig", false, UtilMisc.toMap("productStoreId", productStoreId));
+ } catch (GenericEntityException e) {
+ Debug.logError("Unable to find value for GoogleBaseConfig", module);
+ e.printStackTrace();
+ }
+ if (UtilValidate.isNotEmpty(googleBaseConfig)) {
+ String source = googleBaseConfig.getString("utmSource");
+ String medium = googleBaseConfig.getString("utmMedium");
+ String term = googleBaseConfig.getString("utmTerm");
+ String content = googleBaseConfig.getString("utmContent");
+ String campaign = googleBaseConfig.getString("utmCampaign");
+
+ if (UtilValidate.isNotEmpty(source)) {
+ utmSource = "?utm_source=" + source;
+ } else {
+ utmSource = "";
+ }
+ if (UtilValidate.isNotEmpty(medium)) {
+ utmMedium = "&utm_medium=" + medium;
+ } else {
+ utmMedium = "";
+ }
+ if (UtilValidate.isNotEmpty(term)) {
+ utmTerm = "&utm_term=" + term;
+ } else {
+ utmTerm = "";
+ }
+ if (UtilValidate.isNotEmpty(content)) {
+ utmContent = "&utm_content=" + content;
+ } else {
+ utmContent = "";
+ }
+ if (UtilValidate.isNotEmpty(campaign)) {
+ utmCampaign = "&utm_campaign=" + campaign;
+ } else {
+ utmCampaign = "";
+ }
+ }
+ }
+
if (!webSiteUrl.startsWith("http://") && !webSiteUrl.startsWith("https://")) {
webSiteUrl = "http://" + webSiteUrl;
}
@@ -376,9 +427,10 @@ public class ProductsExportToGoogle {
continue;
}
// TODO: improve this (i.e. get the relative path from the properties file)
- String link = webSiteUrl + "/" + webSiteMountPoint + "/control/product/~product_id=" + prod.getString("productId") + trackingCodeId;
+ String link = webSiteUrl + "/" + webSiteMountPoint + "/control/product/~product_id=" + prod.getString("productId") + trackingCodeId + utmSource + utmMedium + utmTerm + utmContent + utmCampaign;
String productName = null;
String productDescription = null;
+ String productURL = null;
List<GenericValue> productAndInfos = delegator.findByAnd("ProductContentAndInfo", UtilMisc.toMap("productId", prod.getString("productId"), "localeString", localeString, "thruDate", null));
if (productAndInfos.size() > 0) {
for (GenericValue productContentAndInfo : productAndInfos ) {
@@ -389,7 +441,7 @@ public class ProductsExportToGoogle {
if ("LONG_DESCRIPTION".equals(productContentAndInfo.getString("productContentTypeId")))
productDescription = electronicText.getString("textData");
if ("PRODUCT_URL".equals(productContentAndInfo.getString("productContentTypeId")))
- electronicText.getString("textData");
+ productURL = electronicText.getString("textData") + utmSource + utmMedium + utmTerm + utmContent + utmCampaign;
}
} else {
productName = prod.getString("internalName");
Modified: ofbiz/trunk/specialpurpose/googlebase/widget/GoogleBaseForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/googlebase/widget/GoogleBaseForms.xml?rev=1081673&r1=1081672&r2=1081673&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/googlebase/widget/GoogleBaseForms.xml (original)
+++ ofbiz/trunk/specialpurpose/googlebase/widget/GoogleBaseForms.xml Tue Mar 15 06:48:28 2011
@@ -100,6 +100,11 @@ under the License.
</drop-down>
</field>
<field name="accountPassword"><password/></field>
+ <field name="utmSource" title="Campaign Source" tooltip="Use to identify a search engine, newsletter name, or other source. Example: utm_source=google"></field>
+ <field name="utmMedium" title="Campaign Medium" tooltip="Use to identify a medium such as email or cost-per- click. Example: utm_medium=cpc"></field>
+ <field name="utmTerm" title="Campaign Term" tooltip="Used for paid search. Use to note the keywords for this ad. Example: utm_term=running+shoes"></field>
+ <field name="utmContent" title="Campaign Content" tooltip="Used for A/B testing and content-targeted ads. Use to differentiate ads or links that point to the same URL. Examples: utm_content=logolink or utm_content=textlink"></field>
+ <field name="utmCampaign" title="Campaign Name" tooltip="Used for keyword analysis. Use to identify a specific product promotion or strategic campaign. Example: utm_campaign=spring_sale"></field>
<field name="submitButton" title="${uiLabelMap.CommonAdd}"><submit button-type="button"/></field>
</form>