We’ve migrated our documentation to a new site, which means some URLs have changed.
Audience

Implementing a Paywall using the Unified SDK

The Unified SDK does not have specific SDK functions for retrieving Conversion Engine Modules. Technically the Conversion Engine is delivering Content modules, so the content parts of the SDK can be used to retrieve Conversion Engine modules.


For details about the Unified SDKs look at the implementation guides here: Cxense Unified Mobile SDKs


Page View Tracking

Fetching Modules

Code samples Android, Complete javadoc: https://javadoc.jitpack.io/com/cxpublic/cxense-android/1.6.0/javadoc/ 

Retrieve a module

  1. Configure context for widget

    WidgetContext context = new WidgetContext.Builder("https://www.current.url/")
    	.setReferrer("https://www.previous.url/")
       	.build();
    


  2. Fetch results from a module, using the widgetid.

    // Async method
    CxenseSdk.getInstance().loadWidgetRecommendations(widgetId, widgetContext, new LoadCallback<List<WidgetItem>>() {
        @Override
        public void onSuccess(List<WidgetItem> data) {
            // work with loaded items
        }
        @Override
        public void onError(Throwable throwable) {
            // process error
        }
    });
    


  3. Track item click

    CxenseSdk cxenseSdk = CxenseSdk.getInstance();
    // for item
    cxenseSdk.trackClick(item, new LoadCallback() {
        @Override
        public void onSuccess(Object data) {
            // success response from server
        }
     
        @Override
        public void onError(Throwable throwable) {
            // process error
        }
    });
    


  4. Track conversion events - see Product Conversion Tracking - Implementation Guide

    CxenseSdk.getInstance().pushEvents(
            new ConversionEvent.Builder(Collections.singletonList(new UserIdentity("123456", "cxd")), BuildConfig.SITE_ID, "0ab24abee9a85d869b29f46c837144", ConversionEvent.FUNNEL_TYPE_CONVERT_PRODUCT)
                    .setPrice(12.25)
                    .setRenewalFrequency("1wC")
                    .build()
    );
    


  5. Track visibility:

    CxenseSdk.getInstance().reportWidgetVisibilities(
            new LoadCallback() {
                @Override
                public void onSuccess(Object data) {
                    // success response from server
                }
    
                @Override
                public void onError(Throwable throwable) {
                    // process error
                }
            },
            new Impression("clickUrl1", 1),
            new Impression("clickUrl2", 5)
    );
    


  6. To add Custom User Data use setParametesrs and setCategories (both required). It is required that keys are in lowercase to match. Any upper case letters on the categories will not match in the CCE UI, since all keys are lowercased. Sample request including Custom User Data below:

    // there is the only required parameter for a context: URL
    Map<String, String> categories = new HashMap<>();
    categories.put("subscriber", "yes");
    WidgetContext context = new WidgetContext.Builder("https://www.current.url/")
    	.setReferrer("https://www.previous.url/")
        .setParameters(Arrays.asList(
        	new ContextParameter("subscriber", "yes")
        ))
        .setCategories(categories)
        .build();
     
    


Result set

The result set will be a List of WidgetItem

All properties are retirieved using  getProperties ()

Free - open article

If the article is open, the result will contain one item of type "free". 

CxenseSdk.getInstance().loadWidgetRecommendations(widgetId, widgetContext, new LoadCallback<List<WidgetItem>>() {
	@Override
    public void onSuccess(List<WidgetItem> data) {
    	// if data contains one item, check if type == free
        if (data.size() == 1) {
			if ("free".equals(data.get(0).getProperties().get("type"))) {
				// do something since article is open
            } else {
	    		// article is locked
		    }
		}
	}

	@Override
	public void onError(Throwable throwable) {
		// process error
	}
  });
 

When processing the result set on the server side any items which are not of type "free" can be considered a locked down article.

When returning a promotion or article then the items will contain the meta data of the resulting promotion, with image, title, urls etc. This can be rendered in the APP.

Last updated: