Saturday, December 1, 2018

Tracking Outgoing Link Clicks

 This is to record events in Google Analytics whenever someone clicks an outbound link on our website.

  • Event Category: Outside Interactions
  • Event Action: Outbound Link Clicked
  • Event Label: [Click URL]
Google Tag Manager can detect DOM events triggered by the browser such as clicks on elements and form submissions. This is known as Auto-Event tracking, because we are listening for default events and not having to write any additional code on the website.
To accomplish our goal, we can listen for all clicks on <a> elements, where the HREF attribute does not contain our domain name.

Enable the Click URL variable

In order to determine if a link is an internal or outbound one, we need to know the value of the HREF attribute. GTM can automatically record this and set it in a variable.

Go to the Variables screen and then click the Configure button.


Check the Click URL checkbox and then close the popup window. After that, you’ll see the Click URL variable will be available under the Built-In Variables table.

Create a trigger

First, create a trigger which will only fire when an outbound link is clicked. Click the Triggers menu item and then the New button.
Name your trigger  Click - Outbound Link.
Click the ‘Choose a trigger type to begin…’ text and select Just Links in the menu that appears.


We need to have the trigger to fire on outbound link clicks, not all link clicks, so need to select the Some Link Clicks radio button. In the appeared boxes, add a condition where Click URL does not contain store.com. Then save the trigger. Now this created trigger can be used to fire any tags we only want to fire when outbound links are clicked.


Create a tag

Create a new Universal Analytics tag, giving it the name GA Outbound Link Click.
Then enter your Google Analytics property ID, and then change Track Type from Pageview to Event.
Set the event category to Outside Interactions.
Set event action to Outbound Link Clicked.
Set event label to the Click URL variable (click on the brick icon to the right of the input field for a list of available variables). Once inserted, the variable name is surrounded by double curly braces. This means this field will be replaced at run-time with the action value of the clicked URL.


Set the trigger

In the Triggering section, click the pencil icon and select the Click - Outbound Link trigger we created earlier. Then save the tag.


Now you can check that the GTM debugger which shows your tag firing when you click on the links other than store.com.

Friday, November 30, 2018

Tracking all page views with Google Analytics

This will track all the page views.

Create a new tag
Click on the Tags menu and hit the ‘NEW’ button. Give your tag the name as ‘GA Base Tag’.











Choose tag type
Click on the ‘Choose a tag type to begin setup’ text and select ‘Universal Analytics’ from the tag library.














Configure tag options
Enter your Google Analytics property ID in the ‘Tracking ID’ field (this can be found in your Google Analytics account).















Set the trigger
Select the 'All Pages' trigger, so GTM knows to deploy this tag on all pages.





Your tag looks like the below, then click the save button. Your tag is now created!


Configure a Google Tag Manager Account and Container

To create a GTM account and container :


Navigate to Google Tag Manager:
Go to https://tagmanager.google.com and log in with your Google account.

Enter an account name: Give your account name.


Enter a container name: Give your container name.











Create the container:
Click on the create button. Your Google Tag Manager container will be created, and you’ll be given with some HTML script code. This code must be placed on every page of your website.
















Click OK to close the pop-up window and then you’ll be taken to the GTM admin screen.












Thursday, March 15, 2018

Integrate WSO2 API Store with an external IAM using the Okta OAuth Authorization Server

In this guide, we explain how to integrate the WSO2 API Store with an external Identity and Access Management (IAM) by using the Okta OAuth Authorization Server, which is an open source IAM, to manage the OAuth clients and tokens required by WSO2 API Manager. We have a sample client implementation that consumes APIs exposed by Okta OAuth.

For more information, please refer below doc [1] & video [2]:

Working with WSO2 kafka inbound endpoint

To use the Kafka inbound endpoint, download Apache Kafka.
To configure the Kafka inbound endpoint, copy the following client libraries from the <KAFKA_HOME>/lib directory to the <ESB_HOME>/repository/components/lib directory (Tested with ESB 4.9.0).
  • kafka_2.12-0.11.0.0.jar, 
  • scala-parser-combinators_2.12-1.0.4.jar, 
  • metrics-core-2.2.0.jar
  • kafka-clients-0.11.0.0.jar, 
  • zkclient-0.10.jar, 
  • metrics-core-3.2.2.jar, 
  • zookeeper-3.4.10.jar, 
  • scala-library-2.12.2.jar
Add jaas.conf file to <ESB_HOME>/repository/conf/security. Please refer this doc to get jaas.conf file.

Sample Inbound configuration

Following is a sample kafka configuration that can consume messages using the specified topic or topics :
<?xml version="1.0" encoding="UTF-8"?>
<inboundEndpoint xmlns="http://ws.apache.org/ns/synapse"
                 name="kafka"
                 sequence="request"
                 onError="fault"
                 class="org.wso2.carbon.inbound.kafka.KafkaMessageConsumer"
                 suspend="false">
   <parameters>
      <parameter name="coordination">true</parameter>
      <parameter name="interval">10</parameter>
      <parameter name="topic.names">test</parameter>
      <parameter name="value.deserializer">org.apache.kafka.common.serialization.StringDeserializer</parameter>
      <parameter name="bootstrap.servers">localhost:9092</parameter>
      <parameter name="poll.timeout">100</parameter>
      <parameter name="contentType">application/json</parameter>
      <parameter name="group.id">hello</parameter>
      <parameter name="key.deserializer">org.apache.kafka.common.serialization.StringDeserializer</parameter>
      <parameter name="inbound.behavior">polling</parameter>
      <parameter name="sequential">true</parameter>
   </parameters>
</inboundEndpoint>

It is also possible to add the above inbound configuration via the Management Console:














Run the following command to start the ZooKeeper server :

bin/zookeeper-server-start.sh config/zookeeper.properties

Run the following command to start the Kafka server :
bin/kafka-server-start.sh config/server.properties

Start the kafka producer using :
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test

After the executing the above command, a console will be prompt then send the following message using console producer :
{"test":"wso2"}

Configuring the sample scenario 

Create a sample sequence as below :
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="request" onError="fault" xmlns="http://ws.apache.org/ns/synapse">
    <log level="full"/>
    <log level="custom">
        <property name="STATUS" value="Fetching inbound endpoint name"/>
        <property expression="$ctx:inbound.endpoint.name"
            name="inboundEndpointName" xmlns:ns="http://org.apache.synapse/xsd"/>
    </log>
</sequence>

The ESB console output will be like below :

[2018-03-15 15:08:38,436]  INFO - LogMediator To: , MessageID: 379c9c2a-7db1-4210-ba0f-7c550c93b9f3, Direction: request, Payload: {"test":"wso2"}
[2018-03-15 15:08:38,443]  INFO - LogMediator STATUS = Fetching inbound endpoint name, inboundEndpointName = kafka